2 * IWineD3D implementation
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2003-2004 Raphael Junqueira
6 * Copyright 2004 Christian Costa
7 * Copyright 2005 Oliver Stieber
8 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
9 * Copyright 2009-2010 Henri Verbeet for CodeWeavers
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wined3d_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
31 WINE_DECLARE_DEBUG_CHANNEL(d3d_caps
);
33 #define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
35 /* The d3d device ID */
36 static const GUID IID_D3DDEVICE_D3DUID
= { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
38 /* Extension detection */
40 const char *extension_string
;
41 GL_SupportedExt extension
;
45 {"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE
, 0 },
46 {"GL_APPLE_fence", APPLE_FENCE
, 0 },
47 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS
, 0 },
48 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE
, 0 },
49 {"GL_APPLE_flush_render", APPLE_FLUSH_RENDER
, 0 },
50 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422
, 0 },
53 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT
, 0 },
54 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT
, 0 },
55 {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP
, 0 },
56 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE
, 0 },
57 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS
, 0 },
58 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM
, 0 },
59 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER
, 0 },
60 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT
, 0 },
61 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4
, 0 },
62 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL
, 0 },
63 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX
, 0 },
64 {"GL_ARB_imaging", ARB_IMAGING
, 0 },
65 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE
, 0 },
66 {"GL_ARB_multisample", ARB_MULTISAMPLE
, 0 }, /* needs GLX_ARB_MULTISAMPLE as well */
67 {"GL_ARB_multitexture", ARB_MULTITEXTURE
, 0 },
68 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY
, 0 },
69 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT
, 0 },
70 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS
, 0 },
71 {"GL_ARB_point_sprite", ARB_POINT_SPRITE
, 0 },
72 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX
, 0 },
73 {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS
, 0 },
74 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD
, 0 },
75 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100
, 0 },
76 {"GL_ARB_shadow", ARB_SHADOW
, 0 },
77 {"GL_ARB_sync", ARB_SYNC
, 0 },
78 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP
, 0 },
79 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION
, 0 },
80 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC
, 0 },
81 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP
, 0 },
82 {"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD
, 0 },
83 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE
, 0 },
84 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3
, 0 },
85 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT
, 0 },
86 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT
, 0 },
87 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO
, MAKEDWORD_VERSION(2, 0) },
88 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE
, 0 },
89 {"GL_ARB_texture_rg", ARB_TEXTURE_RG
, 0 },
90 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA
, 0 },
91 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND
, 0 },
92 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT
, 0 },
93 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM
, 0 },
94 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER
, 0 },
97 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER
, 0 },
98 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL
, 0 },
99 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC
, 0 },
100 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3
, 0 },
101 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE
, 0 },
104 {"GL_EXT_blend_color", EXT_BLEND_COLOR
, 0 },
105 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE
, 0 },
106 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE
, 0 },
107 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX
, 0 },
108 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST
, 0 },
109 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2
, 0 },
110 {"GL_EXT_fog_coord", EXT_FOG_COORD
, 0 },
111 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT
, 0 },
112 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE
, 0 },
113 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT
, 0 },
114 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS
, 0 },
115 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4
, 0 },
116 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL
, 0 },
117 {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE
, 0 },
118 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS
, 0 },
119 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX
, 0 },
120 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR
, 0 },
121 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE
, 0 },
122 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP
, 0 },
123 {"GL_EXT_texture3D", EXT_TEXTURE3D
, MAKEDWORD_VERSION(1, 2) },
124 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC
, 0 },
125 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC
, 0 },
126 {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD
, 0 },
127 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE
, 0 },
128 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3
, 0 },
129 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC
, 0 },
130 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS
, 0 },
131 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB
, 0 },
132 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE
, 0 },
133 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA
, 0 },
136 {"GL_NV_depth_clamp", NV_DEPTH_CLAMP
, 0 },
137 {"GL_NV_fence", NV_FENCE
, 0 },
138 {"GL_NV_fog_distance", NV_FOG_DISTANCE
, 0 },
139 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM
, 0 },
140 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2
, 0 },
141 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION
, 0 },
142 {"GL_NV_half_float", NV_HALF_FLOAT
, 0 },
143 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT
, 0 },
144 {"GL_NV_point_sprite", NV_POINT_SPRITE
, 0 },
145 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS
, 0 },
146 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2
, 0 },
147 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION
, 0 },
148 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4
, 0 },
149 {"GL_NV_texture_shader", NV_TEXTURE_SHADER
, 0 },
150 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2
, 0 },
151 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM
, 0 },
152 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1
, 0 },
153 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2
, 0 },
154 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION
, 0 },
155 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3
, 0 },
158 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP
, 0 },
161 /**********************************************************
162 * Utility functions follow
163 **********************************************************/
165 const struct min_lookup minMipLookup
[] =
167 /* NONE POINT LINEAR */
168 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
169 {{GL_NEAREST
, GL_NEAREST_MIPMAP_NEAREST
, GL_NEAREST_MIPMAP_LINEAR
}}, /* POINT*/
170 {{GL_LINEAR
, GL_LINEAR_MIPMAP_NEAREST
, GL_LINEAR_MIPMAP_LINEAR
}}, /* LINEAR */
173 const struct min_lookup minMipLookup_noFilter
[] =
175 /* NONE POINT LINEAR */
176 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
177 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
178 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* LINEAR */
181 const struct min_lookup minMipLookup_noMip
[] =
183 /* NONE POINT LINEAR */
184 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
185 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
186 {{GL_LINEAR
, GL_LINEAR
, GL_LINEAR
}}, /* LINEAR */
189 const GLenum magLookup
[] =
191 /* NONE POINT LINEAR */
192 GL_NEAREST
, GL_NEAREST
, GL_LINEAR
,
195 const GLenum magLookup_noFilter
[] =
197 /* NONE POINT LINEAR */
198 GL_NEAREST
, GL_NEAREST
, GL_NEAREST
,
201 /* drawStridedSlow attributes */
202 glAttribFunc position_funcs
[WINED3D_FFP_EMIT_COUNT
];
203 glAttribFunc diffuse_funcs
[WINED3D_FFP_EMIT_COUNT
];
204 glAttribFunc specular_func_3ubv
;
205 glAttribFunc specular_funcs
[WINED3D_FFP_EMIT_COUNT
];
206 glAttribFunc normal_funcs
[WINED3D_FFP_EMIT_COUNT
];
207 glMultiTexCoordFunc multi_texcoord_funcs
[WINED3D_FFP_EMIT_COUNT
];
210 * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
211 * i.e., there is no GL Context - Get a default rendering context to enable the
212 * function query some info from GL.
215 struct wined3d_fake_gl_ctx
221 HGLRC restore_gl_ctx
;
224 static void WineD3D_ReleaseFakeGLContext(struct wined3d_fake_gl_ctx
*ctx
)
226 TRACE_(d3d_caps
)("Destroying fake GL context.\n");
228 if (!pwglMakeCurrent(NULL
, NULL
))
230 ERR_(d3d_caps
)("Failed to disable fake GL context.\n");
233 if (!pwglDeleteContext(ctx
->gl_ctx
))
235 DWORD err
= GetLastError();
236 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx
->gl_ctx
, err
);
239 ReleaseDC(ctx
->wnd
, ctx
->dc
);
240 DestroyWindow(ctx
->wnd
);
242 if (ctx
->restore_gl_ctx
&& !pwglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
244 ERR_(d3d_caps
)("Failed to restore previous GL context.\n");
248 /* Do not call while under the GL lock. */
249 static BOOL
WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx
*ctx
)
251 PIXELFORMATDESCRIPTOR pfd
;
254 TRACE("getting context...\n");
256 ctx
->restore_dc
= pwglGetCurrentDC();
257 ctx
->restore_gl_ctx
= pwglGetCurrentContext();
259 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
260 ctx
->wnd
= CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME
, "WineD3D fake window",
261 WS_OVERLAPPEDWINDOW
, 10, 10, 10, 10, NULL
, NULL
, NULL
, NULL
);
264 ERR_(d3d_caps
)("Failed to create a window.\n");
268 ctx
->dc
= GetDC(ctx
->wnd
);
271 ERR_(d3d_caps
)("Failed to get a DC.\n");
275 /* PixelFormat selection */
276 ZeroMemory(&pfd
, sizeof(pfd
));
277 pfd
.nSize
= sizeof(pfd
);
279 pfd
.dwFlags
= PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER
| PFD_DRAW_TO_WINDOW
; /* PFD_GENERIC_ACCELERATED */
280 pfd
.iPixelType
= PFD_TYPE_RGBA
;
282 pfd
.iLayerType
= PFD_MAIN_PLANE
;
284 iPixelFormat
= ChoosePixelFormat(ctx
->dc
, &pfd
);
287 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
288 ERR_(d3d_caps
)("Can't find a suitable iPixelFormat.\n");
291 DescribePixelFormat(ctx
->dc
, iPixelFormat
, sizeof(pfd
), &pfd
);
292 SetPixelFormat(ctx
->dc
, iPixelFormat
, &pfd
);
294 /* Create a GL context. */
295 ctx
->gl_ctx
= pwglCreateContext(ctx
->dc
);
298 WARN_(d3d_caps
)("Error creating default context for capabilities initialization.\n");
302 /* Make it the current GL context. */
303 if (!context_set_current(NULL
))
305 ERR_(d3d_caps
)("Failed to clear current D3D context.\n");
308 if (!pwglMakeCurrent(ctx
->dc
, ctx
->gl_ctx
))
310 ERR_(d3d_caps
)("Failed to make fake GL context current.\n");
317 if (ctx
->gl_ctx
) pwglDeleteContext(ctx
->gl_ctx
);
319 if (ctx
->dc
) ReleaseDC(ctx
->wnd
, ctx
->dc
);
321 if (ctx
->wnd
) DestroyWindow(ctx
->wnd
);
323 if (ctx
->restore_gl_ctx
&& !pwglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
325 ERR_(d3d_caps
)("Failed to restore previous GL context.\n");
331 /* Adjust the amount of used texture memory */
332 unsigned int WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl
*device
, unsigned int glram
)
334 struct wined3d_adapter
*adapter
= device
->adapter
;
336 adapter
->UsedTextureRam
+= glram
;
337 TRACE("Adjusted gl ram by %d to %d\n", glram
, adapter
->UsedTextureRam
);
338 return adapter
->UsedTextureRam
;
341 static void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
)
343 HeapFree(GetProcessHeap(), 0, adapter
->gl_info
.formats
);
344 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
347 ULONG CDECL
wined3d_incref(struct wined3d
*wined3d
)
349 ULONG refcount
= InterlockedIncrement(&wined3d
->ref
);
351 TRACE("%p increasing refcount to %u.\n", wined3d
, refcount
);
356 ULONG CDECL
wined3d_decref(struct wined3d
*wined3d
)
358 ULONG refcount
= InterlockedDecrement(&wined3d
->ref
);
360 TRACE("%p decreasing refcount to %u.\n", wined3d
, refcount
);
366 for (i
= 0; i
< wined3d
->adapter_count
; ++i
)
368 wined3d_adapter_cleanup(&wined3d
->adapters
[i
]);
370 HeapFree(GetProcessHeap(), 0, wined3d
);
376 /**********************************************************
377 * IWineD3D parts follows
378 **********************************************************/
380 /* GL locking is done by the caller */
381 static inline BOOL
test_arb_vs_offset_limit(const struct wined3d_gl_info
*gl_info
)
385 const char *testcode
=
387 "PARAM C[66] = { program.env[0..65] };\n"
389 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
390 "ARL A0.x, zero.x;\n"
391 "MOV result.position, C[A0.x + 65];\n"
395 GL_EXTCALL(glGenProgramsARB(1, &prog
));
397 ERR("Failed to create an ARB offset limit test program\n");
399 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
400 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
401 strlen(testcode
), testcode
));
404 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
405 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
407 } else TRACE("OpenGL implementation allows offsets > 63\n");
409 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
410 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
411 checkGLcall("ARB vp offset limit test cleanup");
416 static DWORD
ver_for_ext(GL_SupportedExt ext
)
419 for (i
= 0; i
< (sizeof(EXTENSION_MAP
) / sizeof(*EXTENSION_MAP
)); ++i
) {
420 if(EXTENSION_MAP
[i
].extension
== ext
) {
421 return EXTENSION_MAP
[i
].version
;
427 static BOOL
match_amd_r300_to_500(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
428 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
430 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
431 if (device
== CARD_AMD_RADEON_9500
) return TRUE
;
432 if (device
== CARD_AMD_RADEON_X700
) return TRUE
;
433 if (device
== CARD_AMD_RADEON_X1600
) return TRUE
;
437 static BOOL
match_geforce5(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
438 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
440 if (card_vendor
== HW_VENDOR_NVIDIA
)
442 if (device
== CARD_NVIDIA_GEFORCEFX_5200
||
443 device
== CARD_NVIDIA_GEFORCEFX_5600
||
444 device
== CARD_NVIDIA_GEFORCEFX_5800
)
452 static BOOL
match_apple(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
453 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
455 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
456 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
457 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
459 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
460 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
461 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
462 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
463 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
464 * the chance that other implementations support them is rather small since Win32 QuickTime uses
465 * DirectDraw, not OpenGL.
467 * This test has been moved into wined3d_guess_gl_vendor()
469 if (gl_vendor
== GL_VENDOR_APPLE
)
476 /* Context activation is done by the caller. */
477 static void test_pbo_functionality(struct wined3d_gl_info
*gl_info
)
479 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
480 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
481 * all the texture. This function detects this bug by its symptom and disables PBOs
484 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
485 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
486 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
487 * read back is compared to the original. If they are equal PBOs are assumed to work,
488 * otherwise the PBO extension is disabled. */
490 static const unsigned int pattern
[] =
492 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
493 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
494 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
495 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
497 unsigned int check
[sizeof(pattern
) / sizeof(pattern
[0])];
499 /* No PBO -> No point in testing them. */
500 if (!gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
]) return;
504 while (glGetError());
505 glGenTextures(1, &texture
);
506 glBindTexture(GL_TEXTURE_2D
, texture
);
508 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAX_LEVEL
, 0);
509 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 0);
510 checkGLcall("Specifying the PBO test texture");
512 GL_EXTCALL(glGenBuffersARB(1, &pbo
));
513 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, pbo
));
514 GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB
, sizeof(pattern
), pattern
, GL_STREAM_DRAW_ARB
));
515 checkGLcall("Specifying the PBO test pbo");
517 glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
518 checkGLcall("Loading the PBO test texture");
520 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, 0));
523 wglFinish(); /* just to be sure */
525 memset(check
, 0, sizeof(check
));
527 glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, check
);
528 checkGLcall("Reading back the PBO test texture");
530 glDeleteTextures(1, &texture
);
531 GL_EXTCALL(glDeleteBuffersARB(1, &pbo
));
532 checkGLcall("PBO test cleanup");
536 if (memcmp(check
, pattern
, sizeof(check
)))
538 WARN_(d3d_caps
)("PBO test failed, read back data doesn't match original.\n");
539 WARN_(d3d_caps
)("Disabling PBOs. This may result in slower performance.\n");
540 gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
] = FALSE
;
544 TRACE_(d3d_caps
)("PBO test successful.\n");
548 static BOOL
match_apple_intel(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
549 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
551 return (card_vendor
== HW_VENDOR_INTEL
) && (gl_vendor
== GL_VENDOR_APPLE
);
554 static BOOL
match_apple_nonr500ati(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
555 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
557 if (gl_vendor
!= GL_VENDOR_APPLE
) return FALSE
;
558 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
559 if (device
== CARD_AMD_RADEON_X1600
) return FALSE
;
563 static BOOL
match_fglrx(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
564 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
566 return gl_vendor
== GL_VENDOR_FGLRX
;
570 static BOOL
match_dx10_capable(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
571 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
573 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
574 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
575 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
576 * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
579 * dx10 cards usually have 64 varyings */
580 return gl_info
->limits
.glsl_varyings
> 44;
583 /* A GL context is provided by the caller */
584 static BOOL
match_allows_spec_alpha(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
585 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
590 if (!gl_info
->supported
[EXT_SECONDARY_COLOR
]) return FALSE
;
594 GL_EXTCALL(glSecondaryColorPointerEXT
)(4, GL_UNSIGNED_BYTE
, 4, data
);
595 error
= glGetError();
598 if(error
== GL_NO_ERROR
)
600 TRACE("GL Implementation accepts 4 component specular color pointers\n");
605 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
606 debug_glerror(error
));
611 static BOOL
match_apple_nvts(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 if (!match_apple(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
)) return FALSE
;
615 return gl_info
->supported
[NV_TEXTURE_SHADER
];
618 /* A GL context is provided by the caller */
619 static BOOL
match_broken_nv_clip(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
620 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
625 const char *testcode
=
627 "OPTION NV_vertex_program2;\n"
628 "MOV result.clip[0], 0.0;\n"
629 "MOV result.position, 0.0;\n"
632 if (!gl_info
->supported
[NV_VERTEX_PROGRAM2_OPTION
]) return FALSE
;
637 GL_EXTCALL(glGenProgramsARB(1, &prog
));
640 ERR("Failed to create the NVvp clip test program\n");
644 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
645 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
646 strlen(testcode
), testcode
));
647 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &pos
);
650 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
651 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
655 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
657 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
658 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
659 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
665 /* Context activation is done by the caller. */
666 static BOOL
match_fbo_tex_update(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
667 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
669 char data
[4 * 4 * 4];
673 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
) return FALSE
;
675 memset(data
, 0xcc, sizeof(data
));
679 glGenTextures(1, &tex
);
680 glBindTexture(GL_TEXTURE_2D
, tex
);
681 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
682 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
683 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
684 checkGLcall("glTexImage2D");
686 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
687 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
688 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
689 checkGLcall("glFramebufferTexture2D");
691 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
692 if (status
!= GL_FRAMEBUFFER_COMPLETE
) ERR("FBO status %#x\n", status
);
693 checkGLcall("glCheckFramebufferStatus");
695 memset(data
, 0x11, sizeof(data
));
696 glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
697 checkGLcall("glTexSubImage2D");
699 glClearColor(0.996f
, 0.729f
, 0.745f
, 0.792f
);
700 glClear(GL_COLOR_BUFFER_BIT
);
701 checkGLcall("glClear");
703 glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
704 checkGLcall("glGetTexImage");
706 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 0, 0);
707 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
708 glBindTexture(GL_TEXTURE_2D
, 0);
709 checkGLcall("glBindTexture");
711 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
712 glDeleteTextures(1, &tex
);
713 checkGLcall("glDeleteTextures");
717 return *(DWORD
*)data
== 0x11111111;
720 static void quirk_arb_constants(struct wined3d_gl_info
*gl_info
)
722 TRACE_(d3d_caps
)("Using ARB vs constant limit(=%u) for GLSL.\n", gl_info
->limits
.arb_vs_native_constants
);
723 gl_info
->limits
.glsl_vs_float_constants
= gl_info
->limits
.arb_vs_native_constants
;
724 TRACE_(d3d_caps
)("Using ARB ps constant limit(=%u) for GLSL.\n", gl_info
->limits
.arb_ps_native_constants
);
725 gl_info
->limits
.glsl_ps_float_constants
= gl_info
->limits
.arb_ps_native_constants
;
728 static void quirk_apple_glsl_constants(struct wined3d_gl_info
*gl_info
)
730 quirk_arb_constants(gl_info
);
731 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
732 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
733 * allow 48 different offsets or other helper immediate values. */
734 TRACE_(d3d_caps
)("Reserving 12 GLSL constants for compiler private use.\n");
735 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 12);
738 /* fglrx crashes with a very bad kernel panic if GL_POINT_SPRITE_ARB is set to GL_COORD_REPLACE_ARB
739 * on more than one texture unit. This means that the d3d9 visual point size test will cause a
740 * kernel panic on any machine running fglrx 9.3(latest that supports r300 to r500 cards). This
741 * quirk only enables point sprites on the first texture unit. This keeps point sprites working in
742 * most games, but avoids the crash
744 * A more sophisticated way would be to find all units that need texture coordinates and enable
745 * point sprites for one if only one is found, and software emulate point sprites in drawStridedSlow
746 * if more than one unit needs texture coordinates(This requires software ffp and vertex shaders though)
748 * Note that disabling the extension entirely does not gain predictability because there is no point
749 * sprite capability flag in d3d, so the potential rendering bugs are the same if we disable the extension. */
750 static void quirk_one_point_sprite(struct wined3d_gl_info
*gl_info
)
752 if (gl_info
->supported
[ARB_POINT_SPRITE
])
754 TRACE("Limiting point sprites to one texture unit.\n");
755 gl_info
->limits
.point_sprite_units
= 1;
759 static void quirk_amd_dx9(struct wined3d_gl_info
*gl_info
)
761 quirk_arb_constants(gl_info
);
763 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
764 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
765 * If real NP2 textures are used, the driver falls back to software. We could just remove the
766 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconventient
767 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
768 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
769 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
771 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
772 * has this extension promoted to core. The extension loading code sets this extension supported
773 * due to that, so this code works on fglrx as well. */
774 if(gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
776 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
777 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
778 gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
] = TRUE
;
781 /* fglrx has the same structural issues as the one described in quirk_apple_glsl_constants, although
782 * it is generally more efficient. Reserve just 8 constants. */
783 TRACE_(d3d_caps
)("Reserving 8 GLSL constants for compiler private use.\n");
784 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 8);
787 static void quirk_no_np2(struct wined3d_gl_info
*gl_info
)
789 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
790 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
791 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
792 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
793 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
794 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
796 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
797 * triggering the software fallback. There is not much we can do here apart from disabling the
798 * software-emulated extension and reenable ARB_tex_rect (which was previously disabled
799 * in IWineD3DImpl_FillGLCaps).
800 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
801 * post-processing effects in the game "Max Payne 2").
802 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
803 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
804 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
805 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = TRUE
;
808 static void quirk_texcoord_w(struct wined3d_gl_info
*gl_info
)
810 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
811 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
812 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
813 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
814 * according to the spec.
816 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
817 * makes the shader slower and eats instruction slots which should be available to the d3d app.
819 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
820 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
821 * this workaround is activated on cards that do not need it, it won't break things, just affect
822 * performance negatively. */
823 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
824 gl_info
->quirks
|= WINED3D_QUIRK_SET_TEXCOORD_W
;
827 static void quirk_clip_varying(struct wined3d_gl_info
*gl_info
)
829 gl_info
->quirks
|= WINED3D_QUIRK_GLSL_CLIP_VARYING
;
832 static void quirk_allows_specular_alpha(struct wined3d_gl_info
*gl_info
)
834 gl_info
->quirks
|= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
;
837 static void quirk_apple_nvts(struct wined3d_gl_info
*gl_info
)
839 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
840 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
843 static void quirk_disable_nvvp_clip(struct wined3d_gl_info
*gl_info
)
845 gl_info
->quirks
|= WINED3D_QUIRK_NV_CLIP_BROKEN
;
848 static void quirk_fbo_tex_update(struct wined3d_gl_info
*gl_info
)
850 gl_info
->quirks
|= WINED3D_QUIRK_FBO_TEX_UPDATE
;
855 BOOL (*match
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
856 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
);
857 void (*apply
)(struct wined3d_gl_info
*gl_info
);
858 const char *description
;
861 static const struct driver_quirk quirk_table
[] =
864 match_amd_r300_to_500
,
866 "AMD GLSL constant and normalized texrect quirk"
868 /* MacOS advertises more GLSL vertex shader uniforms than supported by the hardware, and if more are
869 * used it falls back to software. While the compiler can detect if the shader uses all declared
870 * uniforms, the optimization fails if the shader uses relative addressing. So any GLSL shader
871 * using relative addressing falls back to software.
873 * ARB vp gives the correct amount of uniforms, so use it instead of GLSL. */
876 quirk_apple_glsl_constants
,
877 "Apple GLSL uniform override"
882 "Geforce 5 NP2 disable"
887 "Init texcoord .w for Apple Intel GPU driver"
890 match_apple_nonr500ati
,
892 "Init texcoord .w for Apple ATI >= r600 GPU driver"
896 quirk_one_point_sprite
,
897 "Fglrx point sprite crash workaround"
902 "Reserved varying for gl_ClipPos"
905 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
906 * GL implementations accept it. The Mac GL is the only implementation known to
909 * If we can pass 4 component specular colors, do it, because (a) we don't have
910 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
911 * passes specular alpha to the pixel shader if any is used. Otherwise the
912 * specular alpha is used to pass the fog coordinate, which we pass to opengl
913 * via GL_EXT_fog_coord.
915 match_allows_spec_alpha
,
916 quirk_allows_specular_alpha
,
917 "Allow specular alpha quirk"
920 /* The pixel formats provided by GL_NV_texture_shader are broken on OSX
925 "Apple NV_texture_shader disable"
928 match_broken_nv_clip
,
929 quirk_disable_nvvp_clip
,
930 "Apple NV_vertex_program clip bug quirk"
933 match_fbo_tex_update
,
934 quirk_fbo_tex_update
,
935 "FBO rebind for attachment updates"
939 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
940 * reporting a driver version is moot because we are not the Windows driver, and we have different
941 * bugs, features, etc.
943 * The driver version has the form "x.y.z.w".
945 * "x" is the Windows version the driver is meant for:
952 * "y" is the maximum Direct3D version the driver supports.
953 * y -> d3d version mapping:
962 * "z" is the subversion number.
964 * "w" is the vendor specific driver build number.
967 struct driver_version_information
969 enum wined3d_display_driver driver
;
970 enum wined3d_driver_model driver_model
;
971 const char *driver_name
; /* name of Windows driver */
972 WORD version
; /* version word ('y'), contained in low word of DriverVersion.HighPart */
973 WORD subversion
; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
974 WORD build
; /* build number ('w'), contained in low word of DriverVersion.LowPart */
977 /* The driver version table contains driver information for different devices on several OS versions. */
978 static const struct driver_version_information driver_version_table
[] =
981 * - Radeon HD2x00 (R600) and up supported by current drivers.
982 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
983 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
984 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
985 {DRIVER_AMD_RAGE_128PRO
, DRIVER_MODEL_NT5X
, "ati2dvaa.dll", 13, 3279, 0},
986 {DRIVER_AMD_R100
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6614},
987 {DRIVER_AMD_R300
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6764},
988 {DRIVER_AMD_R600
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 8681},
989 {DRIVER_AMD_R300
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
990 {DRIVER_AMD_R600
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
993 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
994 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
995 * igxprd32.dll but the GMA800 driver was never updated. */
996 {DRIVER_INTEL_GMA800
, DRIVER_MODEL_NT5X
, "ialmrnt5.dll", 14, 10, 3889},
997 {DRIVER_INTEL_GMA900
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4764},
998 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4926},
999 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 5218},
1000 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 14, 10, 1504},
1001 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 15, 10, 1666},
1004 * - Geforce6 and newer cards are supported by the current driver (197.x) on XP-Win7
1005 * - GeforceFX support is up to 173.x on <= XP
1006 * - Geforce2MX/3/4 up to 96.x on <= XP
1007 * - TNT/Geforce1/2 up to 71.x on <= XP
1008 * All version numbers used below are from the Linux nvidia drivers. */
1009 {DRIVER_NVIDIA_TNT
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 7186},
1010 {DRIVER_NVIDIA_GEFORCE2MX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 9371},
1011 {DRIVER_NVIDIA_GEFORCEFX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 11, 7516},
1012 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 15, 11, 9745},
1013 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT6X
, "nvd3dum.dll", 15, 11, 9745},
1016 struct gpu_description
1018 WORD vendor
; /* reported PCI card vendor ID */
1019 WORD card
; /* reported PCI card device ID */
1020 const char *description
; /* Description of the card e.g. NVIDIA RIVA TNT */
1021 enum wined3d_display_driver driver
;
1022 unsigned int vidmem
;
1025 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1026 * found on a board containing a specific GPU. */
1027 static const struct gpu_description gpu_description_table
[] =
1030 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT
, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT
, 16 },
1031 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT2
, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1032 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE
, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT
, 32 },
1033 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2
, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1034 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2_MX
, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX
,32 },
1035 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE3
, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1036 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_MX
, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1037 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_TI4200
, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX
,64, },
1038 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5200
, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX
, 64 },
1039 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5600
, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX
, 128 },
1040 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5800
, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX
, 256 },
1041 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6200
, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6
, 64 },
1042 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6600GT
, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6
, 128 },
1043 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6800
, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6
, 128 },
1044 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7300
, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6
, 256 },
1045 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7400
, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6
, 256 },
1046 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7600
, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1047 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7800GT
, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1048 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8300GS
, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1049 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8400GS
, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1050 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600GT
, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1051 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600MGT
, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1052 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTS
, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE6
, 320 },
1053 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTX
, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE6
, 768 },
1054 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9200
, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE6
, 256 },
1055 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9400GT
, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1056 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9500GT
, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1057 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9600GT
, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE6
, 384 },
1058 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9800GT
, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1059 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_210
, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE6
, 512 },
1060 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT220
, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE6
, 512 },
1061 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT240
, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE6
, 512 },
1062 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX260
, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE6
, 1024},
1063 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX275
, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE6
, 896 },
1064 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX280
, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE6
, 1024},
1065 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT320M
, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1066 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT325M
, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1067 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT330
, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE6
, 1024},
1068 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS350M
, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1069 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460
, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE6
, 768 },
1070 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX465
, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE6
, 1024},
1071 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX470
, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE6
, 1280},
1072 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX480
, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE6
, 1536},
1074 {HW_VENDOR_AMD
, CARD_AMD_RAGE_128PRO
, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO
, 16 },
1075 {HW_VENDOR_AMD
, CARD_AMD_RADEON_7200
, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100
, 32 },
1076 {HW_VENDOR_AMD
, CARD_AMD_RADEON_8500
, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100
, 64 },
1077 {HW_VENDOR_AMD
, CARD_AMD_RADEON_9500
, "ATI Radeon 9500", DRIVER_AMD_R300
, 64 },
1078 {HW_VENDOR_AMD
, CARD_AMD_RADEON_XPRESS_200M
, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300
, 64 },
1079 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X700
, "ATI Radeon X700 SE", DRIVER_AMD_R300
, 128 },
1080 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X1600
, "ATI Radeon X1600 Series", DRIVER_AMD_R300
, 128 },
1081 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2350
, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600
, 256 },
1082 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2600
, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600
, 256 },
1083 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2900
, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600
, 512 },
1084 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD3200
, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600
, 128 },
1085 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4350
, "ATI Radeon HD 4350", DRIVER_AMD_R600
, 256 },
1086 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4600
, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600
, 512 },
1087 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4700
, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600
, 512 },
1088 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4800
, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600
, 512 },
1089 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5400
, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600
, 512 },
1090 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5600
, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600
, 512 },
1091 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5700
, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600
, 512 },
1092 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5800
, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600
, 1024},
1093 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5900
, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600
, 1024},
1094 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6310
, "AMD Radeon HD 6310 Graphics", DRIVER_AMD_R600
, 1024},
1095 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6800
, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600
, 1024},
1096 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6900
, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600
, 2048},
1098 {HW_VENDOR_INTEL
, CARD_INTEL_I830G
, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1099 {HW_VENDOR_INTEL
, CARD_INTEL_I855G
, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1100 {HW_VENDOR_INTEL
, CARD_INTEL_I865G
, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1101 {HW_VENDOR_INTEL
, CARD_INTEL_I915G
, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1102 {HW_VENDOR_INTEL
, CARD_INTEL_I915GM
, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1103 {HW_VENDOR_INTEL
, CARD_INTEL_I945GM
, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950
, 64 },
1104 {HW_VENDOR_INTEL
, CARD_INTEL_X3100
, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000
, 128},
1105 {HW_VENDOR_INTEL
, CARD_INTEL_GM45
, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000
, 512}
1108 static const struct driver_version_information
*get_driver_version_info(enum wined3d_display_driver driver
,
1109 enum wined3d_driver_model driver_model
)
1113 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver
, driver_model
);
1114 for (i
= 0; i
< (sizeof(driver_version_table
) / sizeof(driver_version_table
[0])); i
++)
1116 const struct driver_version_information
*entry
= &driver_version_table
[i
];
1118 if (entry
->driver
== driver
&& entry
->driver_model
== driver_model
)
1120 TRACE_(d3d_caps
)("Found driver '%s' version=%d subversion=%d build=%d\n",
1121 entry
->driver_name
, entry
->version
, entry
->subversion
, entry
->build
);
1129 static void init_driver_info(struct wined3d_driver_info
*driver_info
,
1130 enum wined3d_pci_vendor vendor
, enum wined3d_pci_device device
)
1132 OSVERSIONINFOW os_version
;
1133 WORD driver_os_version
;
1135 enum wined3d_display_driver driver
= DRIVER_UNKNOWN
;
1136 enum wined3d_driver_model driver_model
;
1137 const struct driver_version_information
*version_info
;
1139 if (wined3d_settings
.pci_vendor_id
!= PCI_VENDOR_NONE
)
1141 TRACE_(d3d_caps
)("Overriding PCI vendor ID with: %04x\n", wined3d_settings
.pci_vendor_id
);
1142 vendor
= wined3d_settings
.pci_vendor_id
;
1144 driver_info
->vendor
= vendor
;
1146 if (wined3d_settings
.pci_device_id
!= PCI_DEVICE_NONE
)
1148 TRACE_(d3d_caps
)("Overriding PCI device ID with: %04x\n", wined3d_settings
.pci_device_id
);
1149 device
= wined3d_settings
.pci_device_id
;
1151 driver_info
->device
= device
;
1153 /* Set a default amount of video memory (64MB). In general this code isn't used unless the user
1154 * overrides the pci ids to a card which is not in our database. */
1155 driver_info
->vidmem
= WINE_DEFAULT_VIDMEM
;
1157 memset(&os_version
, 0, sizeof(os_version
));
1158 os_version
.dwOSVersionInfoSize
= sizeof(os_version
);
1159 if (!GetVersionExW(&os_version
))
1161 ERR("Failed to get OS version, reporting 2000/XP.\n");
1162 driver_os_version
= 6;
1163 driver_model
= DRIVER_MODEL_NT5X
;
1167 TRACE("OS version %u.%u.\n", os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1168 switch (os_version
.dwMajorVersion
)
1171 /* If needed we could distinguish between 9x and NT4, but this code won't make
1172 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1174 driver_os_version
= 4;
1175 driver_model
= DRIVER_MODEL_WIN9X
;
1179 driver_os_version
= 6;
1180 driver_model
= DRIVER_MODEL_NT5X
;
1184 if (os_version
.dwMinorVersion
== 0)
1186 driver_os_version
= 7;
1187 driver_model
= DRIVER_MODEL_NT6X
;
1191 if (os_version
.dwMinorVersion
> 1)
1193 FIXME("Unhandled OS version %u.%u, reporting Win 7.\n",
1194 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1196 driver_os_version
= 8;
1197 driver_model
= DRIVER_MODEL_NT6X
;
1202 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1203 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1204 driver_os_version
= 6;
1205 driver_model
= DRIVER_MODEL_NT5X
;
1210 /* When we reach this stage we always have a vendor or device id (it can be a default one).
1211 * This means that unless the ids are overriden, we will always find a GPU description. */
1212 for (i
= 0; i
< (sizeof(gpu_description_table
) / sizeof(gpu_description_table
[0])); i
++)
1214 if (vendor
== gpu_description_table
[i
].vendor
&& device
== gpu_description_table
[i
].card
)
1216 TRACE_(d3d_caps
)("Found card %04x:%04x in driver DB.\n", vendor
, device
);
1218 driver_info
->description
= gpu_description_table
[i
].description
;
1219 driver_info
->vidmem
= gpu_description_table
[i
].vidmem
* 1024*1024;
1220 driver
= gpu_description_table
[i
].driver
;
1225 if (wined3d_settings
.emulated_textureram
)
1227 TRACE_(d3d_caps
)("Overriding amount of video memory with: %d byte\n", wined3d_settings
.emulated_textureram
);
1228 driver_info
->vidmem
= wined3d_settings
.emulated_textureram
;
1231 /* Try to obtain driver version information for the current Windows version. This fails in
1233 * - the gpu is not available on the currently selected OS version:
1234 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1235 * version information for the current Windows version is returned instead of faked info.
1236 * We do the same and assume the default Windows version to emulate is WinXP.
1238 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1239 * For now return the XP driver info. Perhaps later on we should return VESA.
1241 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1242 * This could be an indication that our database is not up to date, so this should be fixed.
1244 version_info
= get_driver_version_info(driver
, driver_model
);
1247 driver_info
->name
= version_info
->driver_name
;
1248 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1249 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1253 version_info
= get_driver_version_info(driver
, DRIVER_MODEL_NT5X
);
1256 driver_info
->name
= version_info
->driver_name
;
1257 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1258 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1262 driver_info
->description
= "Direct3D HAL";
1263 driver_info
->name
= "Display";
1264 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, 15);
1265 driver_info
->version_low
= MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1267 FIXME("Unable to find a driver/device info for vendor_id=%#x device_id=%#x for driver_model=%d\n",
1268 vendor
, device
, driver_model
);
1272 TRACE_(d3d_caps
)("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1273 driver_info
->version_high
, driver_info
->version_low
);
1276 /* Context activation is done by the caller. */
1277 static void fixup_extensions(struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
1278 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
1282 for (i
= 0; i
< (sizeof(quirk_table
) / sizeof(*quirk_table
)); ++i
)
1284 if (!quirk_table
[i
].match(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
)) continue;
1285 TRACE_(d3d_caps
)("Applying driver quirk \"%s\".\n", quirk_table
[i
].description
);
1286 quirk_table
[i
].apply(gl_info
);
1289 /* Find out if PBOs work as they are supposed to. */
1290 test_pbo_functionality(gl_info
);
1293 static DWORD
wined3d_parse_gl_version(const char *gl_version
)
1295 const char *ptr
= gl_version
;
1299 if (major
<= 0) ERR_(d3d_caps
)("Invalid opengl major version: %d.\n", major
);
1301 while (isdigit(*ptr
)) ++ptr
;
1302 if (*ptr
++ != '.') ERR_(d3d_caps
)("Invalid opengl version string: %s.\n", debugstr_a(gl_version
));
1306 TRACE_(d3d_caps
)("Found OpenGL version: %d.%d.\n", major
, minor
);
1308 return MAKEDWORD_VERSION(major
, minor
);
1311 static enum wined3d_gl_vendor
wined3d_guess_gl_vendor(struct wined3d_gl_info
*gl_info
, const char *gl_vendor_string
, const char *gl_renderer
)
1314 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1315 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1316 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1318 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1319 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1320 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1321 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1322 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1323 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1324 * DirectDraw, not OpenGL. */
1325 if (gl_info
->supported
[APPLE_FENCE
]
1326 && gl_info
->supported
[APPLE_CLIENT_STORAGE
]
1327 && gl_info
->supported
[APPLE_FLUSH_RENDER
]
1328 && gl_info
->supported
[APPLE_YCBCR_422
])
1329 return GL_VENDOR_APPLE
;
1331 if (strstr(gl_vendor_string
, "NVIDIA"))
1332 return GL_VENDOR_NVIDIA
;
1334 if (strstr(gl_vendor_string
, "ATI"))
1335 return GL_VENDOR_FGLRX
;
1337 if (strstr(gl_vendor_string
, "Intel(R)")
1338 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1339 || strstr(gl_renderer
, "Intel")
1340 || strstr(gl_vendor_string
, "Intel Inc."))
1341 return GL_VENDOR_INTEL
;
1343 if (strstr(gl_vendor_string
, "Mesa")
1344 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1345 || strstr(gl_vendor_string
, "DRI R300 Project")
1346 || strstr(gl_vendor_string
, "X.Org R300 Project")
1347 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1348 || strstr(gl_vendor_string
, "VMware, Inc.")
1349 || strstr(gl_renderer
, "Mesa")
1350 || strstr(gl_renderer
, "Gallium"))
1351 return GL_VENDOR_MESA
;
1353 FIXME_(d3d_caps
)("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1354 debugstr_a(gl_vendor_string
));
1356 return GL_VENDOR_UNKNOWN
;
1359 static enum wined3d_pci_vendor
wined3d_guess_card_vendor(const char *gl_vendor_string
, const char *gl_renderer
)
1361 if (strstr(gl_vendor_string
, "NVIDIA")
1362 || strstr(gl_vendor_string
, "nouveau"))
1363 return HW_VENDOR_NVIDIA
;
1365 if (strstr(gl_vendor_string
, "ATI")
1366 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1367 || strstr(gl_vendor_string
, "X.Org R300 Project")
1368 || strstr(gl_renderer
, "AMD")
1369 || strstr(gl_renderer
, "R100")
1370 || strstr(gl_renderer
, "R200")
1371 || strstr(gl_renderer
, "R300")
1372 || strstr(gl_renderer
, "R600")
1373 || strstr(gl_renderer
, "R700"))
1374 return HW_VENDOR_AMD
;
1376 if (strstr(gl_vendor_string
, "Intel(R)")
1377 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1378 || strstr(gl_renderer
, "Intel")
1379 || strstr(gl_vendor_string
, "Intel Inc."))
1380 return HW_VENDOR_INTEL
;
1382 if (strstr(gl_vendor_string
, "Mesa")
1383 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1384 || strstr(gl_vendor_string
, "VMware, Inc."))
1385 return HW_VENDOR_SOFTWARE
;
1387 FIXME_(d3d_caps
)("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string
));
1389 return HW_VENDOR_NVIDIA
;
1394 static enum wined3d_pci_device
select_card_nvidia_binary(const struct wined3d_gl_info
*gl_info
,
1395 const char *gl_renderer
)
1399 if (WINE_D3D10_CAPABLE(gl_info
))
1403 const char *renderer
;
1404 enum wined3d_pci_device id
;
1408 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480
}, /* Geforce 400 - highend */
1409 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470
}, /* Geforce 400 - midend high */
1410 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465
}, /* Geforce 400 - midend */
1411 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460
}, /* Geforce 400 - midend */
1412 {"GT 330", CARD_NVIDIA_GEFORCE_GT330
}, /* Geforce 300 - highend */
1413 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1414 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1415 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1416 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1417 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M
}, /* Geforce 300 - midend mobile */
1418 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1419 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1420 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1421 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275
}, /* Geforce 200 - midend high */
1422 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260
}, /* Geforce 200 - midend */
1423 {"GT 240", CARD_NVIDIA_GEFORCE_GT240
}, /* Geforce 200 - midend */
1424 {"GT 220", CARD_NVIDIA_GEFORCE_GT220
}, /* Geforce 200 - lowend */
1425 {"Geforce 310", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1426 {"Geforce 305", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1427 {"Geforce 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1428 {"G 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1429 {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1430 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1431 {"9800", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1432 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1433 {"9600", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1434 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1435 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1436 {"9500", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1437 {"9400", CARD_NVIDIA_GEFORCE_9400GT
}, /* Geforce 9 - lowend */
1438 {"9300", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1439 {"9200", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1440 {"9100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1441 {"G 100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1442 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX
}, /* Geforce 8 - highend high */
1443 {"8800", CARD_NVIDIA_GEFORCE_8800GTS
}, /* Geforce 8 - highend */
1444 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1445 {"8700", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1446 {"8600", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1447 {"8500", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1448 {"8400", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1449 {"8300", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1450 {"8200", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1451 {"8100", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1454 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1456 if (strstr(gl_renderer
, cards
[i
].renderer
))
1460 /* Geforce8-compatible fall back if the GPU is not in the list yet */
1461 return CARD_NVIDIA_GEFORCE_8300GS
;
1464 /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
1465 * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
1467 if (WINE_D3D9_CAPABLE(gl_info
) && gl_info
->supported
[NV_VERTEX_PROGRAM3
])
1471 const char *renderer
;
1472 enum wined3d_pci_device id
;
1476 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1477 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1478 {"7950", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1479 {"7900", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1480 {"7800", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1481 {"7700", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1482 {"7600", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1483 {"7400", CARD_NVIDIA_GEFORCE_7400
}, /* Geforce 7 - lower medium */
1484 {"7300", CARD_NVIDIA_GEFORCE_7300
}, /* Geforce 7 - lowend */
1485 {"6800", CARD_NVIDIA_GEFORCE_6800
}, /* Geforce 6 - highend */
1486 {"6700", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1487 {"6610", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1488 {"6600", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1491 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1493 if (strstr(gl_renderer
, cards
[i
].renderer
))
1497 /* Geforce 6/7 - lowend */
1498 return CARD_NVIDIA_GEFORCE_6200
; /* Geforce 6100/6150/6200/7300/7400/7500 */
1501 if (WINE_D3D9_CAPABLE(gl_info
))
1503 /* GeforceFX - highend */
1504 if (strstr(gl_renderer
, "5800")
1505 || strstr(gl_renderer
, "5900")
1506 || strstr(gl_renderer
, "5950")
1507 || strstr(gl_renderer
, "Quadro FX"))
1509 return CARD_NVIDIA_GEFORCEFX_5800
;
1512 /* GeforceFX - midend */
1513 if (strstr(gl_renderer
, "5600")
1514 || strstr(gl_renderer
, "5650")
1515 || strstr(gl_renderer
, "5700")
1516 || strstr(gl_renderer
, "5750"))
1518 return CARD_NVIDIA_GEFORCEFX_5600
;
1521 /* GeforceFX - lowend */
1522 return CARD_NVIDIA_GEFORCEFX_5200
; /* GeforceFX 5100/5200/5250/5300/5500 */
1525 if (WINE_D3D8_CAPABLE(gl_info
))
1527 if (strstr(gl_renderer
, "GeForce4 Ti") || strstr(gl_renderer
, "Quadro4"))
1529 return CARD_NVIDIA_GEFORCE4_TI4200
; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
1532 return CARD_NVIDIA_GEFORCE3
; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
1535 if (WINE_D3D7_CAPABLE(gl_info
))
1537 if (strstr(gl_renderer
, "GeForce4 MX"))
1539 return CARD_NVIDIA_GEFORCE4_MX
; /* MX420/MX440/MX460/MX4000 */
1542 if (strstr(gl_renderer
, "GeForce2 MX") || strstr(gl_renderer
, "Quadro2 MXR"))
1544 return CARD_NVIDIA_GEFORCE2_MX
; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
1547 if (strstr(gl_renderer
, "GeForce2") || strstr(gl_renderer
, "Quadro2"))
1549 return CARD_NVIDIA_GEFORCE2
; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
1552 return CARD_NVIDIA_GEFORCE
; /* Geforce 256/DDR, Quadro */
1555 if (strstr(gl_renderer
, "TNT2"))
1557 return CARD_NVIDIA_RIVA_TNT2
; /* Riva TNT2 standard/M64/Pro/Ultra */
1560 return CARD_NVIDIA_RIVA_TNT
; /* Riva TNT, Vanta */
1563 static enum wined3d_pci_device
select_card_amd_binary(const struct wined3d_gl_info
*gl_info
,
1564 const char *gl_renderer
)
1566 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1568 * Beware: renderer string do not match exact card model,
1569 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1570 if (WINE_D3D10_CAPABLE(gl_info
))
1576 const char *renderer
;
1577 enum wined3d_pci_device id
;
1582 {"HD 5870", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS PRO */
1583 {"HD 5850", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS XT */
1584 {"HD 5800", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1585 {"HD 5770", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER XT */
1586 {"HD 5750", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER LE */
1587 {"HD 5700", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1588 {"HD 5670", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD XT */
1589 {"HD 5570", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1590 {"HD 5550", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1591 {"HD 5450", CARD_AMD_RADEON_HD5400
}, /* Radeon EG CEDAR PRO */
1593 {"HD 4890", CARD_AMD_RADEON_HD4800
}, /* Radeon RV790 */
1594 {"HD 4870", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1595 {"HD 4850", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1596 {"HD 4830", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1597 {"HD 4800", CARD_AMD_RADEON_HD4800
}, /* Radeon RV7xx HD48xx generic renderer string */
1598 {"HD 4770", CARD_AMD_RADEON_HD4700
}, /* Radeon RV740 */
1599 {"HD 4700", CARD_AMD_RADEON_HD4700
}, /* Radeon RV7xx HD47xx generic renderer string */
1600 {"HD 4670", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1601 {"HD 4650", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1602 {"HD 4600", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1603 {"HD 4550", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1604 {"HD 4350", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1605 /* R600/R700 integrated */
1606 {"HD 3300", CARD_AMD_RADEON_HD3200
},
1607 {"HD 3200", CARD_AMD_RADEON_HD3200
},
1608 {"HD 3100", CARD_AMD_RADEON_HD3200
},
1610 {"HD 3870", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1611 {"HD 3850", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1612 {"HD 2900", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1613 {"HD 3830", CARD_AMD_RADEON_HD2600
}, /* China-only midend */
1614 {"HD 3690", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1615 {"HD 3650", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1616 {"HD 2600", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1617 {"HD 3470", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1618 {"HD 3450", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1619 {"HD 3430", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1620 {"HD 3400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1621 {"HD 2400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1622 {"HD 2350", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1625 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1627 if (strstr(gl_renderer
, cards
[i
].renderer
))
1631 /* Default for when no GPU has been found */
1632 return CARD_AMD_RADEON_HD3200
;
1635 if (WINE_D3D8_CAPABLE(gl_info
))
1638 if (strstr(gl_renderer
, "X1600")
1639 || strstr(gl_renderer
, "X1650")
1640 || strstr(gl_renderer
, "X1800")
1641 || strstr(gl_renderer
, "X1900")
1642 || strstr(gl_renderer
, "X1950"))
1644 return CARD_AMD_RADEON_X1600
;
1647 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1648 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1649 if (strstr(gl_renderer
, "X700")
1650 || strstr(gl_renderer
, "X800")
1651 || strstr(gl_renderer
, "X850")
1652 || strstr(gl_renderer
, "X1300")
1653 || strstr(gl_renderer
, "X1400")
1654 || strstr(gl_renderer
, "X1450")
1655 || strstr(gl_renderer
, "X1550")
1656 || strstr(gl_renderer
, "X2300")
1657 || strstr(gl_renderer
, "X2500")
1658 || strstr(gl_renderer
, "HD 2300")
1661 return CARD_AMD_RADEON_X700
;
1664 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1665 if (strstr(gl_renderer
, "Radeon Xpress"))
1667 return CARD_AMD_RADEON_XPRESS_200M
;
1671 return CARD_AMD_RADEON_9500
; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
1674 if (WINE_D3D8_CAPABLE(gl_info
))
1676 return CARD_AMD_RADEON_8500
; /* Radeon 8500/9000/9100/9200/9300 */
1679 if (WINE_D3D7_CAPABLE(gl_info
))
1681 return CARD_AMD_RADEON_7200
; /* Radeon 7000/7100/7200/7500 */
1684 return CARD_AMD_RAGE_128PRO
;
1687 static enum wined3d_pci_device
select_card_intel(const struct wined3d_gl_info
*gl_info
,
1688 const char *gl_renderer
)
1690 if (strstr(gl_renderer
, "GM45")) return CARD_INTEL_GM45
;
1691 if (strstr(gl_renderer
, "X3100") || strstr(gl_renderer
, "965GM"))
1693 /* MacOS calls the card GMA X3100, otherwise known as GM965/GL960 */
1694 return CARD_INTEL_X3100
;
1697 if (strstr(gl_renderer
, "GMA 950") || strstr(gl_renderer
, "945GM"))
1699 /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
1700 return CARD_INTEL_I945GM
;
1703 if (strstr(gl_renderer
, "915GM")) return CARD_INTEL_I915GM
;
1704 if (strstr(gl_renderer
, "915G")) return CARD_INTEL_I915G
;
1705 if (strstr(gl_renderer
, "865G")) return CARD_INTEL_I865G
;
1706 if (strstr(gl_renderer
, "855G")) return CARD_INTEL_I855G
;
1707 if (strstr(gl_renderer
, "830G")) return CARD_INTEL_I830G
;
1708 return CARD_INTEL_I915G
;
1712 static enum wined3d_pci_device
select_card_amd_mesa(const struct wined3d_gl_info
*gl_info
,
1713 const char *gl_renderer
)
1717 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1719 * Beware: renderer string do not match exact card model,
1720 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1721 if (strstr(gl_renderer
, "Gallium"))
1723 /* 20101109 - These are never returned by current Gallium radeon
1724 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
1726 * These are returned but not handled: RC410, RV380. */
1729 const char *renderer
;
1730 enum wined3d_pci_device id
;
1734 /* Northern Islands */
1735 {"CAYMAN", CARD_AMD_RADEON_HD6900
},
1736 {"BARTS", CARD_AMD_RADEON_HD6800
},
1737 {"PALM", CARD_AMD_RADEON_HD6310
},
1739 {"HEMLOCK", CARD_AMD_RADEON_HD5900
},
1740 {"CYPRESS", CARD_AMD_RADEON_HD5800
},
1741 {"JUNIPER", CARD_AMD_RADEON_HD5700
},
1742 {"REDWOOD", CARD_AMD_RADEON_HD5600
},
1743 {"CEDAR", CARD_AMD_RADEON_HD5400
},
1745 {"R700", CARD_AMD_RADEON_HD4800
}, /* HD4800 - highend */
1746 {"RV790", CARD_AMD_RADEON_HD4800
},
1747 {"RV770", CARD_AMD_RADEON_HD4800
},
1748 {"RV740", CARD_AMD_RADEON_HD4700
}, /* HD4700 - midend */
1749 {"RV730", CARD_AMD_RADEON_HD4600
}, /* HD4600 - midend */
1750 {"RV710", CARD_AMD_RADEON_HD4350
}, /* HD4500/HD4350 - lowend */
1751 /* R600/R700 integrated */
1752 {"RS880", CARD_AMD_RADEON_HD3200
},
1753 {"RS780", CARD_AMD_RADEON_HD3200
},
1755 {"R680", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1756 {"R600", CARD_AMD_RADEON_HD2900
},
1757 {"RV670", CARD_AMD_RADEON_HD2900
},
1758 {"RV635", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1759 {"RV630", CARD_AMD_RADEON_HD2600
},
1760 {"RV620", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1761 {"RV610", CARD_AMD_RADEON_HD2350
},
1763 {"R580", CARD_AMD_RADEON_X1600
},
1764 {"R520", CARD_AMD_RADEON_X1600
},
1765 {"RV570", CARD_AMD_RADEON_X1600
},
1766 {"RV560", CARD_AMD_RADEON_X1600
},
1767 {"RV535", CARD_AMD_RADEON_X1600
},
1768 {"RV530", CARD_AMD_RADEON_X1600
},
1769 {"RV516", CARD_AMD_RADEON_X700
}, /* X700 is actually R400. */
1770 {"RV515", CARD_AMD_RADEON_X700
},
1772 {"R481", CARD_AMD_RADEON_X700
},
1773 {"R480", CARD_AMD_RADEON_X700
},
1774 {"R430", CARD_AMD_RADEON_X700
},
1775 {"R423", CARD_AMD_RADEON_X700
},
1776 {"R420", CARD_AMD_RADEON_X700
},
1777 {"R410", CARD_AMD_RADEON_X700
},
1778 {"RV410", CARD_AMD_RADEON_X700
},
1779 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400MHz */
1780 {"RS740", CARD_AMD_RADEON_XPRESS_200M
},
1781 {"RS690", CARD_AMD_RADEON_XPRESS_200M
},
1782 {"RS600", CARD_AMD_RADEON_XPRESS_200M
},
1783 {"RS485", CARD_AMD_RADEON_XPRESS_200M
},
1784 {"RS482", CARD_AMD_RADEON_XPRESS_200M
},
1785 {"RS480", CARD_AMD_RADEON_XPRESS_200M
},
1786 {"RS400", CARD_AMD_RADEON_XPRESS_200M
},
1788 {"R360", CARD_AMD_RADEON_9500
},
1789 {"R350", CARD_AMD_RADEON_9500
},
1790 {"R300", CARD_AMD_RADEON_9500
},
1791 {"RV370", CARD_AMD_RADEON_9500
},
1792 {"RV360", CARD_AMD_RADEON_9500
},
1793 {"RV351", CARD_AMD_RADEON_9500
},
1794 {"RV350", CARD_AMD_RADEON_9500
},
1797 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1799 if (strstr(gl_renderer
, cards
[i
].renderer
))
1804 if (WINE_D3D9_CAPABLE(gl_info
))
1808 const char *renderer
;
1809 enum wined3d_pci_device id
;
1814 {"(R700", CARD_AMD_RADEON_HD4800
}, /* HD4800 - highend */
1815 {"(RV790", CARD_AMD_RADEON_HD4800
},
1816 {"(RV770", CARD_AMD_RADEON_HD4800
},
1817 {"(RV740", CARD_AMD_RADEON_HD4700
}, /* HD4700 - midend */
1818 {"(RV730", CARD_AMD_RADEON_HD4600
}, /* HD4600 - midend */
1819 {"(RV710", CARD_AMD_RADEON_HD4350
}, /* HD4500/HD4350 - lowend */
1820 /* R600/R700 integrated */
1821 {"RS880", CARD_AMD_RADEON_HD3200
},
1822 {"RS780", CARD_AMD_RADEON_HD3200
},
1824 {"(R680", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1825 {"(R600", CARD_AMD_RADEON_HD2900
},
1826 {"(RV670", CARD_AMD_RADEON_HD2900
},
1827 {"(RV635", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1828 {"(RV630", CARD_AMD_RADEON_HD2600
},
1829 {"(RV620", CARD_AMD_RADEON_HD2350
}, /* HD2300/HD2400/HD3400 - lowend */
1830 {"(RV610", CARD_AMD_RADEON_HD2350
},
1833 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1835 if (strstr(gl_renderer
, cards
[i
].renderer
))
1840 if (WINE_D3D8_CAPABLE(gl_info
))
1842 return CARD_AMD_RADEON_8500
; /* Radeon 8500/9000/9100/9200/9300 */
1845 if (WINE_D3D7_CAPABLE(gl_info
))
1847 return CARD_AMD_RADEON_7200
; /* Radeon 7000/7100/7200/7500 */
1850 return CARD_AMD_RAGE_128PRO
;
1853 static enum wined3d_pci_device
select_card_nvidia_mesa(const struct wined3d_gl_info
*gl_info
,
1854 const char *gl_renderer
)
1856 if (strstr(gl_renderer
, "Gallium"))
1862 const char *renderer
;
1863 enum wined3d_pci_device id
;
1867 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460
},
1868 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480
},
1869 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M
},
1870 {"NVAC", CARD_NVIDIA_GEFORCE_8200
},
1871 {"NVAA", CARD_NVIDIA_GEFORCE_8200
},
1872 {"NVA8", CARD_NVIDIA_GEFORCE_210
},
1873 {"NVA5", CARD_NVIDIA_GEFORCE_GT220
},
1874 {"NVA3", CARD_NVIDIA_GEFORCE_GT240
},
1875 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280
},
1876 {"NV98", CARD_NVIDIA_GEFORCE_9200
},
1877 {"NV96", CARD_NVIDIA_GEFORCE_9400GT
},
1878 {"NV94", CARD_NVIDIA_GEFORCE_9600GT
},
1879 {"NV92", CARD_NVIDIA_GEFORCE_9800GT
},
1880 {"NV86", CARD_NVIDIA_GEFORCE_8500GT
},
1881 {"NV84", CARD_NVIDIA_GEFORCE_8600GT
},
1882 {"NV68", CARD_NVIDIA_GEFORCE_6200
}, /* 7050 */
1883 {"NV67", CARD_NVIDIA_GEFORCE_6200
}, /* 7000M */
1884 {"NV63", CARD_NVIDIA_GEFORCE_6200
}, /* 7100 */
1885 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX
},
1886 {"NV4E", CARD_NVIDIA_GEFORCE_6200
}, /* 6100 Go / 6150 Go */
1887 {"NV4C", CARD_NVIDIA_GEFORCE_6200
}, /* 6150SE */
1888 {"NV4B", CARD_NVIDIA_GEFORCE_7600
},
1889 {"NV4A", CARD_NVIDIA_GEFORCE_6200
},
1890 {"NV49", CARD_NVIDIA_GEFORCE_7800GT
}, /* 7900 */
1891 {"NV47", CARD_NVIDIA_GEFORCE_7800GT
},
1892 {"NV46", CARD_NVIDIA_GEFORCE_7400
},
1893 {"NV45", CARD_NVIDIA_GEFORCE_6800
},
1894 {"NV44", CARD_NVIDIA_GEFORCE_6200
},
1895 {"NV43", CARD_NVIDIA_GEFORCE_6600GT
},
1896 {"NV42", CARD_NVIDIA_GEFORCE_6800
},
1897 {"NV41", CARD_NVIDIA_GEFORCE_6800
},
1898 {"NV40", CARD_NVIDIA_GEFORCE_6800
},
1899 {"NV38", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5950 Ultra */
1900 {"NV36", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5700/5750 */
1901 {"NV35", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5900 */
1902 {"NV34", CARD_NVIDIA_GEFORCEFX_5200
},
1903 {"NV31", CARD_NVIDIA_GEFORCEFX_5600
},
1904 {"NV30", CARD_NVIDIA_GEFORCEFX_5800
},
1905 {"NV28", CARD_NVIDIA_GEFORCE4_TI4200
},
1906 {"NV25", CARD_NVIDIA_GEFORCE4_TI4200
},
1907 {"NV20", CARD_NVIDIA_GEFORCE3
},
1908 {"NV1F", CARD_NVIDIA_GEFORCE4_MX
}, /* GF4 MX IGP */
1909 {"NV1A", CARD_NVIDIA_GEFORCE2
}, /* GF2 IGP */
1910 {"NV18", CARD_NVIDIA_GEFORCE4_MX
},
1911 {"NV17", CARD_NVIDIA_GEFORCE4_MX
},
1912 {"NV16", CARD_NVIDIA_GEFORCE2
},
1913 {"NV15", CARD_NVIDIA_GEFORCE2
},
1914 {"NV11", CARD_NVIDIA_GEFORCE2_MX
},
1915 {"NV10", CARD_NVIDIA_GEFORCE
},
1916 {"NV05", CARD_NVIDIA_RIVA_TNT2
},
1917 {"NV04", CARD_NVIDIA_RIVA_TNT
},
1918 {"NV03", CARD_NVIDIA_RIVA_128
},
1921 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1923 if (strstr(gl_renderer
, cards
[i
].renderer
))
1928 FIXME_(d3d_caps
)("Unknown renderer %s.\n", debugstr_a(gl_renderer
));
1929 if (WINE_D3D9_CAPABLE(gl_info
)) return CARD_NVIDIA_GEFORCEFX_5600
;
1930 if (WINE_D3D8_CAPABLE(gl_info
)) return CARD_NVIDIA_GEFORCE3
;
1931 if (WINE_D3D7_CAPABLE(gl_info
)) return CARD_NVIDIA_GEFORCE
;
1932 if (WINE_D3D6_CAPABLE(gl_info
)) return CARD_NVIDIA_RIVA_TNT
;
1933 return CARD_NVIDIA_RIVA_128
;
1937 struct vendor_card_selection
1939 enum wined3d_gl_vendor gl_vendor
;
1940 enum wined3d_pci_vendor card_vendor
;
1941 const char *description
; /* Description of the card selector i.e. Apple OS/X Intel */
1942 enum wined3d_pci_device (*select_card
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
);
1945 static const struct vendor_card_selection vendor_card_select_table
[] =
1947 {GL_VENDOR_NVIDIA
, HW_VENDOR_NVIDIA
, "Nvidia binary driver", select_card_nvidia_binary
},
1948 {GL_VENDOR_APPLE
, HW_VENDOR_NVIDIA
, "Apple OSX NVidia binary driver", select_card_nvidia_binary
},
1949 {GL_VENDOR_APPLE
, HW_VENDOR_AMD
, "Apple OSX AMD/ATI binary driver", select_card_amd_binary
},
1950 {GL_VENDOR_APPLE
, HW_VENDOR_INTEL
, "Apple OSX Intel binary driver", select_card_intel
},
1951 {GL_VENDOR_FGLRX
, HW_VENDOR_AMD
, "AMD/ATI binary driver", select_card_amd_binary
},
1952 {GL_VENDOR_MESA
, HW_VENDOR_AMD
, "Mesa AMD/ATI driver", select_card_amd_mesa
},
1953 {GL_VENDOR_MESA
, HW_VENDOR_NVIDIA
, "Mesa Nouveau driver", select_card_nvidia_mesa
},
1954 {GL_VENDOR_MESA
, HW_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
},
1955 {GL_VENDOR_INTEL
, HW_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
}
1959 static enum wined3d_pci_device
wined3d_guess_card(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
1960 enum wined3d_gl_vendor
*gl_vendor
, enum wined3d_pci_vendor
*card_vendor
)
1962 /* Above is a list of Nvidia and ATI GPUs. Both vendors have dozens of
1963 * different GPUs with roughly the same features. In most cases GPUs from a
1964 * certain family differ in clockspeeds, the amount of video memory and the
1965 * number of shader pipelines.
1967 * A Direct3D device object contains the PCI id (vendor + device) of the
1968 * videocard which is used for rendering. Various applications use this
1969 * information to get a rough estimation of the features of the card and
1970 * some might use it for enabling 3d effects only on certain types of
1971 * videocards. In some cases games might even use it to work around bugs
1972 * which happen on certain videocards/driver combinations. The problem is
1973 * that OpenGL only exposes a rendering string containing the name of the
1974 * videocard and not the PCI id.
1976 * Various games depend on the PCI id, so somehow we need to provide one.
1977 * A simple option is to parse the renderer string and translate this to
1978 * the right PCI id. This is a lot of work because there are more than 200
1979 * GPUs just for Nvidia. Various cards share the same renderer string, so
1980 * the amount of code might be 'small' but there are quite a number of
1981 * exceptions which would make this a pain to maintain. Another way would
1982 * be to query the PCI id from the operating system (assuming this is the
1983 * videocard which is used for rendering which is not always the case).
1984 * This would work but it is not very portable. Second it would not work
1985 * well in, let's say, a remote X situation in which the amount of 3d
1986 * features which can be used is limited.
1988 * As said most games only use the PCI id to get an indication of the
1989 * capabilities of the card. It doesn't really matter if the given id is
1990 * the correct one if we return the id of a card with similar 3d features.
1992 * The code below checks the OpenGL capabilities of a videocard and matches
1993 * that to a certain level of Direct3D functionality. Once a card passes
1994 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
1995 * least a GeforceFX. To give a better estimate we do a basic check on the
1996 * renderer string but if that won't pass we return a default card. This
1997 * way is better than maintaining a full card database as even without a
1998 * full database we can return a card with similar features. Second the
1999 * size of the database can be made quite small because when you know what
2000 * type of 3d functionality a card has, you know to which GPU family the
2001 * GPU must belong. Because of this you only have to check a small part of
2002 * the renderer string to distinguishes between different models from that
2005 * The code also selects a default amount of video memory which we will
2006 * use for an estimation of the amount of free texture memory. In case of
2007 * real D3D the amount of texture memory includes video memory and system
2008 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2009 * HyperMemory). We don't know how much system memory can be addressed by
2010 * the system but we can make a reasonable estimation about the amount of
2011 * video memory. If the value is slightly wrong it doesn't matter as we
2012 * didn't include AGP-like memory which makes the amount of addressable
2013 * memory higher and second OpenGL isn't that critical it moves to system
2014 * memory behind our backs if really needed. Note that the amount of video
2015 * memory can be overruled using a registry setting. */
2019 for (i
= 0; i
< (sizeof(vendor_card_select_table
) / sizeof(*vendor_card_select_table
)); ++i
)
2021 if ((vendor_card_select_table
[i
].gl_vendor
!= *gl_vendor
)
2022 || (vendor_card_select_table
[i
].card_vendor
!= *card_vendor
))
2024 TRACE_(d3d_caps
)("Applying card_selector \"%s\".\n", vendor_card_select_table
[i
].description
);
2025 return vendor_card_select_table
[i
].select_card(gl_info
, gl_renderer
);
2028 FIXME_(d3d_caps
)("No card selector available for GL vendor %d and card vendor %04x.\n",
2029 *gl_vendor
, *card_vendor
);
2031 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
2032 * for Nvidia was because the hardware and drivers they make are of good quality. This makes
2033 * them a good generic choice. */
2034 *card_vendor
= HW_VENDOR_NVIDIA
;
2035 if (WINE_D3D9_CAPABLE(gl_info
)) return CARD_NVIDIA_GEFORCEFX_5600
;
2036 if (WINE_D3D8_CAPABLE(gl_info
)) return CARD_NVIDIA_GEFORCE3
;
2037 if (WINE_D3D7_CAPABLE(gl_info
)) return CARD_NVIDIA_GEFORCE
;
2038 if (WINE_D3D6_CAPABLE(gl_info
)) return CARD_NVIDIA_RIVA_TNT
;
2039 return CARD_NVIDIA_RIVA_128
;
2042 static const struct fragment_pipeline
*select_fragment_implementation(struct wined3d_adapter
*adapter
)
2044 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
2045 int vs_selected_mode
, ps_selected_mode
;
2047 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2048 if ((ps_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_GLSL
)
2049 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]) return &arbfp_fragment_pipeline
;
2050 else if (ps_selected_mode
== SHADER_ATI
) return &atifs_fragment_pipeline
;
2051 else if (gl_info
->supported
[NV_REGISTER_COMBINERS
]
2052 && gl_info
->supported
[NV_TEXTURE_SHADER2
]) return &nvts_fragment_pipeline
;
2053 else if (gl_info
->supported
[NV_REGISTER_COMBINERS
]) return &nvrc_fragment_pipeline
;
2054 else return &ffp_fragment_pipeline
;
2057 static const shader_backend_t
*select_shader_backend(struct wined3d_adapter
*adapter
)
2059 int vs_selected_mode
, ps_selected_mode
;
2061 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2062 if (vs_selected_mode
== SHADER_GLSL
|| ps_selected_mode
== SHADER_GLSL
) return &glsl_shader_backend
;
2063 if (vs_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_ARB
) return &arb_program_shader_backend
;
2064 return &none_shader_backend
;
2067 static const struct blit_shader
*select_blit_implementation(struct wined3d_adapter
*adapter
)
2069 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
2070 int vs_selected_mode
, ps_selected_mode
;
2072 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2073 if ((ps_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_GLSL
)
2074 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]) return &arbfp_blit
;
2075 else return &ffp_blit
;
2078 static void load_gl_funcs(struct wined3d_gl_info
*gl_info
, DWORD gl_version
)
2082 #define USE_GL_FUNC(type, pfn, ext, replace) \
2083 if (gl_info->supported[ext]) gl_info->pfn = (type)pwglGetProcAddress(#pfn); \
2084 else if ((ver = ver_for_ext(ext)) && ver <= gl_version) gl_info->pfn = (type)pwglGetProcAddress(#replace); \
2085 else gl_info->pfn = NULL;
2090 #define USE_GL_FUNC(type, pfn, ext, replace) gl_info->pfn = (type)pwglGetProcAddress(#pfn);
2095 /* Context activation is done by the caller. */
2096 static BOOL
IWineD3DImpl_FillGLCaps(struct wined3d_adapter
*adapter
)
2098 struct wined3d_driver_info
*driver_info
= &adapter
->driver_info
;
2099 struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
2100 const char *GL_Extensions
= NULL
;
2101 const char *WGL_Extensions
= NULL
;
2102 const char *gl_vendor_str
, *gl_renderer_str
, *gl_version_str
;
2103 struct fragment_caps fragment_caps
;
2104 enum wined3d_gl_vendor gl_vendor
;
2105 enum wined3d_pci_vendor card_vendor
;
2106 enum wined3d_pci_device device
;
2108 GLfloat gl_floatv
[2];
2114 TRACE_(d3d_caps
)("(%p)\n", gl_info
);
2118 gl_renderer_str
= (const char *)glGetString(GL_RENDERER
);
2119 TRACE_(d3d_caps
)("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str
));
2120 if (!gl_renderer_str
)
2123 ERR_(d3d_caps
)("Received a NULL GL_RENDERER.\n");
2127 gl_vendor_str
= (const char *)glGetString(GL_VENDOR
);
2128 TRACE_(d3d_caps
)("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str
));
2132 ERR_(d3d_caps
)("Received a NULL GL_VENDOR.\n");
2136 /* Parse the GL_VERSION field into major and minor information */
2137 gl_version_str
= (const char *)glGetString(GL_VERSION
);
2138 TRACE_(d3d_caps
)("GL_VERSION: %s.\n", debugstr_a(gl_version_str
));
2139 if (!gl_version_str
)
2142 ERR_(d3d_caps
)("Received a NULL GL_VERSION.\n");
2145 gl_version
= wined3d_parse_gl_version(gl_version_str
);
2148 * Initialize openGL extension related variables
2149 * with Default values
2151 memset(gl_info
->supported
, 0, sizeof(gl_info
->supported
));
2152 gl_info
->limits
.blends
= 1;
2153 gl_info
->limits
.buffers
= 1;
2154 gl_info
->limits
.textures
= 1;
2155 gl_info
->limits
.fragment_samplers
= 1;
2156 gl_info
->limits
.vertex_samplers
= 0;
2157 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
+ gl_info
->limits
.vertex_samplers
;
2158 gl_info
->limits
.sampler_stages
= 1;
2159 gl_info
->limits
.glsl_vs_float_constants
= 0;
2160 gl_info
->limits
.glsl_ps_float_constants
= 0;
2161 gl_info
->limits
.arb_vs_float_constants
= 0;
2162 gl_info
->limits
.arb_vs_native_constants
= 0;
2163 gl_info
->limits
.arb_vs_instructions
= 0;
2164 gl_info
->limits
.arb_vs_temps
= 0;
2165 gl_info
->limits
.arb_ps_float_constants
= 0;
2166 gl_info
->limits
.arb_ps_local_constants
= 0;
2167 gl_info
->limits
.arb_ps_instructions
= 0;
2168 gl_info
->limits
.arb_ps_temps
= 0;
2170 /* Retrieve opengl defaults */
2171 glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
2172 gl_info
->limits
.clipplanes
= min(WINED3DMAXUSERCLIPPLANES
, gl_max
);
2173 TRACE_(d3d_caps
)("ClipPlanes support - num Planes=%d\n", gl_max
);
2175 glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
2176 gl_info
->limits
.lights
= gl_max
;
2177 TRACE_(d3d_caps
)("Lights support - max lights=%d\n", gl_max
);
2179 glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &gl_max
);
2180 gl_info
->limits
.texture_size
= gl_max
;
2181 TRACE_(d3d_caps
)("Maximum texture size support - max texture size=%d\n", gl_max
);
2183 glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE
, gl_floatv
);
2184 gl_info
->limits
.pointsize_min
= gl_floatv
[0];
2185 gl_info
->limits
.pointsize_max
= gl_floatv
[1];
2186 TRACE_(d3d_caps
)("Maximum point size support - max point size=%f\n", gl_floatv
[1]);
2188 /* Parse the gl supported features, in theory enabling parts of our code appropriately. */
2189 GL_Extensions
= (const char *)glGetString(GL_EXTENSIONS
);
2193 ERR_(d3d_caps
)("Received a NULL GL_EXTENSIONS.\n");
2199 TRACE_(d3d_caps
)("GL_Extensions reported:\n");
2201 gl_info
->supported
[WINED3D_GL_EXT_NONE
] = TRUE
;
2203 while (*GL_Extensions
)
2207 while (isspace(*GL_Extensions
)) ++GL_Extensions
;
2208 start
= GL_Extensions
;
2209 while (!isspace(*GL_Extensions
) && *GL_Extensions
) ++GL_Extensions
;
2211 len
= GL_Extensions
- start
;
2214 TRACE_(d3d_caps
)("- %s\n", debugstr_an(start
, len
));
2216 for (i
= 0; i
< (sizeof(EXTENSION_MAP
) / sizeof(*EXTENSION_MAP
)); ++i
)
2218 if (len
== strlen(EXTENSION_MAP
[i
].extension_string
)
2219 && !memcmp(start
, EXTENSION_MAP
[i
].extension_string
, len
))
2221 TRACE_(d3d_caps
)(" FOUND: %s support.\n", EXTENSION_MAP
[i
].extension_string
);
2222 gl_info
->supported
[EXTENSION_MAP
[i
].extension
] = TRUE
;
2228 /* Now work out what GL support this card really has */
2229 load_gl_funcs( gl_info
, gl_version
);
2233 /* Now mark all the extensions supported which are included in the opengl core version. Do this *after*
2234 * loading the functions, otherwise the code above will load the extension entry points instead of the
2235 * core functions, which may not work. */
2236 for (i
= 0; i
< (sizeof(EXTENSION_MAP
) / sizeof(*EXTENSION_MAP
)); ++i
)
2238 if (!gl_info
->supported
[EXTENSION_MAP
[i
].extension
]
2239 && EXTENSION_MAP
[i
].version
<= gl_version
&& EXTENSION_MAP
[i
].version
)
2241 TRACE_(d3d_caps
)(" GL CORE: %s support.\n", EXTENSION_MAP
[i
].extension_string
);
2242 gl_info
->supported
[EXTENSION_MAP
[i
].extension
] = TRUE
;
2246 if (gl_version
>= MAKEDWORD_VERSION(2, 0)) gl_info
->supported
[WINED3D_GL_VERSION_2_0
] = TRUE
;
2248 if (gl_info
->supported
[APPLE_FENCE
])
2250 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
2251 * The apple extension interacts with some other apple exts. Disable the NV
2252 * extension if the apple one is support to prevent confusion in other parts
2254 gl_info
->supported
[NV_FENCE
] = FALSE
;
2256 if (gl_info
->supported
[APPLE_FLOAT_PIXELS
])
2258 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
2260 * The enums are the same:
2261 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881A
2262 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881B
2263 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
2264 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
2265 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140B
2267 if (!gl_info
->supported
[ARB_TEXTURE_FLOAT
])
2269 TRACE_(d3d_caps
)(" IMPLIED: GL_ARB_texture_float support(from GL_APPLE_float_pixels.\n");
2270 gl_info
->supported
[ARB_TEXTURE_FLOAT
] = TRUE
;
2272 if (!gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
2274 TRACE_(d3d_caps
)(" IMPLIED: GL_ARB_half_float_pixel support(from GL_APPLE_float_pixels.\n");
2275 gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
] = TRUE
;
2278 if (gl_info
->supported
[ARB_MAP_BUFFER_RANGE
])
2280 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
2281 * functionality. Prefer the ARB extension */
2282 gl_info
->supported
[APPLE_FLUSH_BUFFER_RANGE
] = FALSE
;
2284 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
2286 TRACE_(d3d_caps
)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
2287 gl_info
->supported
[NV_TEXGEN_REFLECTION
] = TRUE
;
2289 if (!gl_info
->supported
[ARB_DEPTH_CLAMP
] && gl_info
->supported
[NV_DEPTH_CLAMP
])
2291 TRACE_(d3d_caps
)(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
2292 gl_info
->supported
[ARB_DEPTH_CLAMP
] = TRUE
;
2294 if (!gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] && gl_info
->supported
[EXT_VERTEX_ARRAY_BGRA
])
2296 TRACE_(d3d_caps
)(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
2297 gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] = TRUE
;
2299 if (!gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] && gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
])
2301 TRACE_(d3d_caps
)(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
2302 gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] = TRUE
;
2304 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
2306 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2308 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
2309 * are supported. The nv extensions provide the same functionality as the
2310 * ATI one, and a bit more(signed pixelformats). */
2311 gl_info
->supported
[ATI_FRAGMENT_SHADER
] = FALSE
;
2315 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2317 glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV
, &gl_max
);
2318 gl_info
->limits
.general_combiners
= gl_max
;
2319 TRACE_(d3d_caps
)("Max general combiners: %d.\n", gl_max
);
2321 if (gl_info
->supported
[ARB_DRAW_BUFFERS
])
2323 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &gl_max
);
2324 gl_info
->limits
.buffers
= gl_max
;
2325 TRACE_(d3d_caps
)("Max draw buffers: %u.\n", gl_max
);
2327 if (gl_info
->supported
[ARB_MULTITEXTURE
])
2329 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
2330 gl_info
->limits
.textures
= min(MAX_TEXTURES
, gl_max
);
2331 TRACE_(d3d_caps
)("Max textures: %d.\n", gl_info
->limits
.textures
);
2333 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2336 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2337 gl_info
->limits
.fragment_samplers
= min(MAX_FRAGMENT_SAMPLERS
, tmp
);
2341 gl_info
->limits
.fragment_samplers
= max(gl_info
->limits
.fragment_samplers
, gl_max
);
2343 TRACE_(d3d_caps
)("Max fragment samplers: %d.\n", gl_info
->limits
.fragment_samplers
);
2345 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2348 glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2349 gl_info
->limits
.vertex_samplers
= tmp
;
2350 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2351 gl_info
->limits
.combined_samplers
= tmp
;
2353 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
2354 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
2355 * an issue because then the sampler setup only depends on the two shaders. If a pixel
2356 * shader is used with fixed function vertex processing we're fine too because fixed function
2357 * vertex processing doesn't use any samplers. If fixed function fragment processing is
2358 * used we have to make sure that all vertex sampler setups are valid together with all
2359 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
2360 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
2361 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
2362 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
2363 * a fixed function pipeline anymore.
2365 * So this is just a check to check that our assumption holds true. If not, write a warning
2366 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
2367 if (gl_info
->limits
.vertex_samplers
&& gl_info
->limits
.combined_samplers
< 12
2368 && MAX_TEXTURES
+ gl_info
->limits
.vertex_samplers
> gl_info
->limits
.combined_samplers
)
2370 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
2371 gl_info
->limits
.vertex_samplers
, gl_info
->limits
.combined_samplers
);
2372 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
2373 if (gl_info
->limits
.combined_samplers
> MAX_TEXTURES
)
2374 gl_info
->limits
.vertex_samplers
= gl_info
->limits
.combined_samplers
- MAX_TEXTURES
;
2376 gl_info
->limits
.vertex_samplers
= 0;
2381 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
;
2383 TRACE_(d3d_caps
)("Max vertex samplers: %u.\n", gl_info
->limits
.vertex_samplers
);
2384 TRACE_(d3d_caps
)("Max combined samplers: %u.\n", gl_info
->limits
.combined_samplers
);
2386 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
2388 glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB
, &gl_max
);
2389 gl_info
->limits
.blends
= gl_max
;
2390 TRACE_(d3d_caps
)("Max blends: %u.\n", gl_info
->limits
.blends
);
2392 if (gl_info
->supported
[EXT_TEXTURE3D
])
2394 glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT
, &gl_max
);
2395 gl_info
->limits
.texture3d_size
= gl_max
;
2396 TRACE_(d3d_caps
)("Max texture3D size: %d.\n", gl_info
->limits
.texture3d_size
);
2398 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
2400 glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, &gl_max
);
2401 gl_info
->limits
.anisotropy
= gl_max
;
2402 TRACE_(d3d_caps
)("Max anisotropy: %d.\n", gl_info
->limits
.anisotropy
);
2404 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2406 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2407 gl_info
->limits
.arb_ps_float_constants
= gl_max
;
2408 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_ps_float_constants
);
2409 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2410 gl_info
->limits
.arb_ps_native_constants
= gl_max
;
2411 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
2412 gl_info
->limits
.arb_ps_native_constants
);
2413 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2414 gl_info
->limits
.arb_ps_temps
= gl_max
;
2415 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_ps_temps
);
2416 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2417 gl_info
->limits
.arb_ps_instructions
= gl_max
;
2418 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2419 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB
, &gl_max
));
2420 gl_info
->limits
.arb_ps_local_constants
= gl_max
;
2421 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2423 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
])
2425 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2426 gl_info
->limits
.arb_vs_float_constants
= gl_max
;
2427 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_vs_float_constants
);
2428 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2429 gl_info
->limits
.arb_vs_native_constants
= gl_max
;
2430 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
2431 gl_info
->limits
.arb_vs_native_constants
);
2432 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2433 gl_info
->limits
.arb_vs_temps
= gl_max
;
2434 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_vs_temps
);
2435 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2436 gl_info
->limits
.arb_vs_instructions
= gl_max
;
2437 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_vs_instructions
);
2439 if (test_arb_vs_offset_limit(gl_info
)) gl_info
->quirks
|= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT
;
2441 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2443 glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2444 gl_info
->limits
.glsl_vs_float_constants
= gl_max
/ 4;
2445 TRACE_(d3d_caps
)("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info
->limits
.glsl_vs_float_constants
);
2447 if (gl_info
->supported
[ARB_FRAGMENT_SHADER
])
2449 glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2450 gl_info
->limits
.glsl_ps_float_constants
= gl_max
/ 4;
2451 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info
->limits
.glsl_ps_float_constants
);
2452 glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB
, &gl_max
);
2453 gl_info
->limits
.glsl_varyings
= gl_max
;
2454 TRACE_(d3d_caps
)("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max
, gl_max
/ 4);
2456 if (gl_info
->supported
[ARB_SHADING_LANGUAGE_100
])
2458 const char *str
= (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION_ARB
);
2459 unsigned int major
, minor
;
2461 TRACE_(d3d_caps
)("GLSL version string: %s.\n", debugstr_a(str
));
2463 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
2464 sscanf(str
, "%u.%u", &major
, &minor
);
2465 gl_info
->glsl_version
= MAKEDWORD_VERSION(major
, minor
);
2467 if (gl_info
->supported
[NV_LIGHT_MAX_EXPONENT
])
2469 glGetFloatv(GL_MAX_SHININESS_NV
, &gl_info
->limits
.shininess
);
2473 gl_info
->limits
.shininess
= 128.0f
;
2475 if (gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
2477 /* If we have full NP2 texture support, disable
2478 * GL_ARB_texture_rectangle because we will never use it.
2479 * This saves a few redundant glDisable calls. */
2480 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = FALSE
;
2482 if (gl_info
->supported
[ATI_FRAGMENT_SHADER
])
2484 /* Disable NV_register_combiners and fragment shader if this is supported.
2485 * generally the NV extensions are preferred over the ATI ones, and this
2486 * extension is disabled if register_combiners and texture_shader2 are both
2487 * supported. So we reach this place only if we have incomplete NV dxlevel 8
2488 * fragment processing support. */
2489 gl_info
->supported
[NV_REGISTER_COMBINERS
] = FALSE
;
2490 gl_info
->supported
[NV_REGISTER_COMBINERS2
] = FALSE
;
2491 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
2492 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
2494 if (gl_info
->supported
[NV_HALF_FLOAT
])
2496 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
2497 gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
] = TRUE
;
2499 if (gl_info
->supported
[ARB_POINT_SPRITE
])
2501 gl_info
->limits
.point_sprite_units
= gl_info
->limits
.textures
;
2505 gl_info
->limits
.point_sprite_units
= 0;
2507 checkGLcall("extension detection");
2511 adapter
->fragment_pipe
= select_fragment_implementation(adapter
);
2512 adapter
->shader_backend
= select_shader_backend(adapter
);
2513 adapter
->blitter
= select_blit_implementation(adapter
);
2515 adapter
->fragment_pipe
->get_caps(gl_info
, &fragment_caps
);
2516 gl_info
->limits
.texture_stages
= fragment_caps
.MaxTextureBlendStages
;
2517 TRACE_(d3d_caps
)("Max texture stages: %u.\n", gl_info
->limits
.texture_stages
);
2519 /* In some cases the number of texture stages can be larger than the number
2520 * of samplers. The GF4 for example can use only 2 samplers (no fragment
2521 * shaders), but 8 texture stages (register combiners). */
2522 gl_info
->limits
.sampler_stages
= max(gl_info
->limits
.fragment_samplers
, gl_info
->limits
.texture_stages
);
2524 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
2526 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->glIsRenderbuffer
;
2527 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->glBindRenderbuffer
;
2528 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->glDeleteRenderbuffers
;
2529 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->glGenRenderbuffers
;
2530 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->glRenderbufferStorage
;
2531 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->glRenderbufferStorageMultisample
;
2532 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->glGetRenderbufferParameteriv
;
2533 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->glIsFramebuffer
;
2534 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->glBindFramebuffer
;
2535 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->glDeleteFramebuffers
;
2536 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->glGenFramebuffers
;
2537 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->glCheckFramebufferStatus
;
2538 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->glFramebufferTexture1D
;
2539 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->glFramebufferTexture2D
;
2540 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->glFramebufferTexture3D
;
2541 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->glFramebufferRenderbuffer
;
2542 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
= gl_info
->glGetFramebufferAttachmentParameteriv
;
2543 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->glBlitFramebuffer
;
2544 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->glGenerateMipmap
;
2548 if (gl_info
->supported
[EXT_FRAMEBUFFER_OBJECT
])
2550 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->glIsRenderbufferEXT
;
2551 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->glBindRenderbufferEXT
;
2552 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->glDeleteRenderbuffersEXT
;
2553 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->glGenRenderbuffersEXT
;
2554 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->glRenderbufferStorageEXT
;
2555 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->glGetRenderbufferParameterivEXT
;
2556 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->glIsFramebufferEXT
;
2557 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->glBindFramebufferEXT
;
2558 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->glDeleteFramebuffersEXT
;
2559 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->glGenFramebuffersEXT
;
2560 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->glCheckFramebufferStatusEXT
;
2561 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->glFramebufferTexture1DEXT
;
2562 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->glFramebufferTexture2DEXT
;
2563 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->glFramebufferTexture3DEXT
;
2564 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->glFramebufferRenderbufferEXT
;
2565 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
= gl_info
->glGetFramebufferAttachmentParameterivEXT
;
2566 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->glGenerateMipmapEXT
;
2568 else if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
2570 WARN_(d3d_caps
)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
2571 wined3d_settings
.offscreen_rendering_mode
= ORM_BACKBUFFER
;
2573 if (gl_info
->supported
[EXT_FRAMEBUFFER_BLIT
])
2575 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->glBlitFramebufferEXT
;
2577 if (gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
2579 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->glRenderbufferStorageMultisampleEXT
;
2583 /* MRTs are currently only supported when FBOs are used. */
2584 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
2586 gl_info
->limits
.buffers
= 1;
2589 gl_vendor
= wined3d_guess_gl_vendor(gl_info
, gl_vendor_str
, gl_renderer_str
);
2590 card_vendor
= wined3d_guess_card_vendor(gl_vendor_str
, gl_renderer_str
);
2591 TRACE_(d3d_caps
)("found GL_VENDOR (%s)->(0x%04x/0x%04x)\n", debugstr_a(gl_vendor_str
), gl_vendor
, card_vendor
);
2593 device
= wined3d_guess_card(gl_info
, gl_renderer_str
, &gl_vendor
, &card_vendor
);
2594 TRACE_(d3d_caps
)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", card_vendor
, device
);
2596 gl_info
->wrap_lookup
[WINED3DTADDRESS_WRAP
- WINED3DTADDRESS_WRAP
] = GL_REPEAT
;
2597 gl_info
->wrap_lookup
[WINED3DTADDRESS_MIRROR
- WINED3DTADDRESS_WRAP
] =
2598 gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
] ? GL_MIRRORED_REPEAT_ARB
: GL_REPEAT
;
2599 gl_info
->wrap_lookup
[WINED3DTADDRESS_CLAMP
- WINED3DTADDRESS_WRAP
] = GL_CLAMP_TO_EDGE
;
2600 gl_info
->wrap_lookup
[WINED3DTADDRESS_BORDER
- WINED3DTADDRESS_WRAP
] =
2601 gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
] ? GL_CLAMP_TO_BORDER_ARB
: GL_REPEAT
;
2602 gl_info
->wrap_lookup
[WINED3DTADDRESS_MIRRORONCE
- WINED3DTADDRESS_WRAP
] =
2603 gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] ? GL_MIRROR_CLAMP_TO_EDGE_ATI
: GL_REPEAT
;
2605 /* Make sure there's an active HDC else the WGL extensions will fail */
2606 hdc
= pwglGetCurrentDC();
2608 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox */
2609 if(GL_EXTCALL(wglGetExtensionsStringARB
))
2610 WGL_Extensions
= GL_EXTCALL(wglGetExtensionsStringARB(hdc
));
2612 if (!WGL_Extensions
)
2614 ERR(" WGL_Extensions returns NULL\n");
2618 TRACE_(d3d_caps
)("WGL_Extensions reported:\n");
2619 while (*WGL_Extensions
)
2624 while (isspace(*WGL_Extensions
)) WGL_Extensions
++;
2625 Start
= WGL_Extensions
;
2626 while (!isspace(*WGL_Extensions
) && *WGL_Extensions
) ++WGL_Extensions
;
2628 len
= WGL_Extensions
- Start
;
2629 if (!len
|| len
>= sizeof(ThisExtn
))
2632 memcpy(ThisExtn
, Start
, len
);
2633 ThisExtn
[len
] = '\0';
2634 TRACE_(d3d_caps
)("- %s\n", debugstr_a(ThisExtn
));
2636 if (!strcmp(ThisExtn
, "WGL_ARB_pixel_format")) {
2637 gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
] = TRUE
;
2638 TRACE_(d3d_caps
)("FOUND: WGL_ARB_pixel_format support\n");
2640 if (!strcmp(ThisExtn
, "WGL_EXT_swap_control")) {
2641 gl_info
->supported
[WGL_EXT_SWAP_CONTROL
] = TRUE
;
2642 TRACE_(d3d_caps
)("FOUND: WGL_EXT_swap_control support\n");
2644 if (!strcmp(ThisExtn
, "WGL_WINE_pixel_format_passthrough")) {
2645 gl_info
->supported
[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH
] = TRUE
;
2646 TRACE_(d3d_caps
)("FOUND: WGL_WINE_pixel_format_passthrough support\n");
2652 fixup_extensions(gl_info
, gl_renderer_str
, gl_vendor
, card_vendor
, device
);
2653 init_driver_info(driver_info
, card_vendor
, device
);
2654 add_gl_compat_wrappers(gl_info
);
2659 UINT CDECL
wined3d_get_adapter_count(const struct wined3d
*wined3d
)
2661 TRACE_(d3d_caps
)("wined3d %p, reporting %u adapters.\n",
2662 wined3d
, wined3d
->adapter_count
);
2664 return wined3d
->adapter_count
;
2667 HRESULT CDECL
wined3d_register_software_device(struct wined3d
*wined3d
, void *init_function
)
2669 FIXME("wined3d %p, init_function %p stub!\n", wined3d
, init_function
);
2674 HMONITOR CDECL
wined3d_get_adapter_monitor(const struct wined3d
*wined3d
, UINT adapter_idx
)
2676 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u.\n", wined3d
, adapter_idx
);
2678 if (adapter_idx
>= wined3d
->adapter_count
)
2681 return MonitorFromPoint(wined3d
->adapters
[adapter_idx
].monitorPoint
, MONITOR_DEFAULTTOPRIMARY
);
2684 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
2685 of the same bpp but different resolutions */
2687 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2688 UINT CDECL
wined3d_get_adapter_mode_count(const struct wined3d
*wined3d
, UINT adapter_idx
,
2689 enum wined3d_format_id format_id
)
2691 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, format %s.\n", wined3d
, adapter_idx
, debug_d3dformat(format_id
));
2693 if (adapter_idx
>= wined3d
->adapter_count
)
2696 /* TODO: Store modes per adapter and read it from the adapter structure */
2699 const struct wined3d_format
*format
= wined3d_get_format(&wined3d
->adapters
[adapter_idx
].gl_info
, format_id
);
2700 UINT format_bits
= format
->byte_count
* CHAR_BIT
;
2705 memset(&mode
, 0, sizeof(mode
));
2706 mode
.dmSize
= sizeof(mode
);
2708 while (EnumDisplaySettingsExW(NULL
, j
, &mode
, 0))
2712 if (format_id
== WINED3DFMT_UNKNOWN
)
2714 /* This is for D3D8, do not enumerate P8 here */
2715 if (mode
.dmBitsPerPel
== 32 || mode
.dmBitsPerPel
== 16) ++i
;
2717 else if (mode
.dmBitsPerPel
== format_bits
)
2723 TRACE_(d3d_caps
)("Returning %u matching modes (out of %u total) for adapter %u.\n", i
, j
, adapter_idx
);
2729 FIXME_(d3d_caps
)("Adapter not primary display.\n");
2735 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2736 HRESULT CDECL
wined3d_enum_adapter_modes(const struct wined3d
*wined3d
, UINT adapter_idx
,
2737 enum wined3d_format_id format_id
, UINT mode_idx
, WINED3DDISPLAYMODE
*mode
)
2739 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, format %s, mode_idx %u, mode %p.\n",
2740 wined3d
, adapter_idx
, debug_d3dformat(format_id
), mode_idx
, mode
);
2742 /* Validate the parameters as much as possible */
2743 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
2744 || mode_idx
>= wined3d_get_adapter_mode_count(wined3d
, adapter_idx
, format_id
))
2746 return WINED3DERR_INVALIDCALL
;
2749 /* TODO: Store modes per adapter and read it from the adapter structure */
2752 const struct wined3d_format
*format
= wined3d_get_format(&wined3d
->adapters
[adapter_idx
].gl_info
, format_id
);
2753 UINT format_bits
= format
->byte_count
* CHAR_BIT
;
2759 ZeroMemory(&DevModeW
, sizeof(DevModeW
));
2760 DevModeW
.dmSize
= sizeof(DevModeW
);
2762 /* If we are filtering to a specific format (D3D9), then need to skip
2763 all unrelated modes, but if mode is irrelevant (D3D8), then we can
2764 just count through the ones with valid bit depths */
2765 while (i
<= mode_idx
&& EnumDisplaySettingsExW(NULL
, j
++, &DevModeW
, 0))
2767 if (format_id
== WINED3DFMT_UNKNOWN
)
2769 /* This is for D3D8, do not enumerate P8 here */
2770 if (DevModeW
.dmBitsPerPel
== 32 || DevModeW
.dmBitsPerPel
== 16) ++i
;
2772 else if (DevModeW
.dmBitsPerPel
== format_bits
)
2780 TRACE_(d3d_caps
)("No modes found for format (%x - %s)\n", format_id
, debug_d3dformat(format_id
));
2781 return WINED3DERR_INVALIDCALL
;
2785 /* Now get the display mode via the calculated index */
2786 if (EnumDisplaySettingsExW(NULL
, ModeIdx
, &DevModeW
, 0))
2788 mode
->Width
= DevModeW
.dmPelsWidth
;
2789 mode
->Height
= DevModeW
.dmPelsHeight
;
2790 mode
->RefreshRate
= DEFAULT_REFRESH_RATE
;
2791 if (DevModeW
.dmFields
& DM_DISPLAYFREQUENCY
)
2792 mode
->RefreshRate
= DevModeW
.dmDisplayFrequency
;
2794 if (format_id
== WINED3DFMT_UNKNOWN
)
2795 mode
->Format
= pixelformat_for_depth(DevModeW
.dmBitsPerPel
);
2797 mode
->Format
= format_id
;
2801 TRACE_(d3d_caps
)("Requested mode %u out of range.\n", mode_idx
);
2802 return WINED3DERR_INVALIDCALL
;
2805 TRACE_(d3d_caps
)("W %d H %d rr %d fmt (%x - %s) bpp %u\n",
2806 mode
->Width
, mode
->Height
, mode
->RefreshRate
, mode
->Format
,
2807 debug_d3dformat(mode
->Format
), DevModeW
.dmBitsPerPel
);
2811 FIXME_(d3d_caps
)("Adapter not primary display\n");
2817 HRESULT CDECL
wined3d_get_adapter_display_mode(const struct wined3d
*wined3d
, UINT adapter_idx
,
2818 WINED3DDISPLAYMODE
*mode
)
2820 TRACE("wined3d %p, adapter_idx %u, display_mode %p.\n", wined3d
, adapter_idx
, mode
);
2822 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
)
2823 return WINED3DERR_INVALIDCALL
;
2830 ZeroMemory(&DevModeW
, sizeof(DevModeW
));
2831 DevModeW
.dmSize
= sizeof(DevModeW
);
2833 EnumDisplaySettingsExW(NULL
, ENUM_CURRENT_SETTINGS
, &DevModeW
, 0);
2834 mode
->Width
= DevModeW
.dmPelsWidth
;
2835 mode
->Height
= DevModeW
.dmPelsHeight
;
2836 bpp
= DevModeW
.dmBitsPerPel
;
2837 mode
->RefreshRate
= DEFAULT_REFRESH_RATE
;
2838 if (DevModeW
.dmFields
&DM_DISPLAYFREQUENCY
)
2839 mode
->RefreshRate
= DevModeW
.dmDisplayFrequency
;
2840 mode
->Format
= pixelformat_for_depth(bpp
);
2844 FIXME_(d3d_caps
)("Adapter not primary display\n");
2847 TRACE_(d3d_caps
)("returning w:%d, h:%d, ref:%d, fmt:%s\n", mode
->Width
,
2848 mode
->Height
, mode
->RefreshRate
, debug_d3dformat(mode
->Format
));
2852 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
2853 and fields being inserted in the middle, a new structure is used in place */
2854 HRESULT CDECL
wined3d_get_adapter_identifier(const struct wined3d
*wined3d
,
2855 UINT adapter_idx
, DWORD flags
, WINED3DADAPTER_IDENTIFIER
*identifier
)
2857 const struct wined3d_adapter
*adapter
;
2860 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, flags %#x, indentifier %p.\n",
2861 wined3d
, adapter_idx
, flags
, identifier
);
2863 if (adapter_idx
>= wined3d
->adapter_count
)
2864 return WINED3DERR_INVALIDCALL
;
2866 adapter
= &wined3d
->adapters
[adapter_idx
];
2868 /* Return the information requested */
2869 TRACE_(d3d_caps
)("device/Vendor Name and Version detection using FillGLCaps\n");
2871 if (identifier
->driver_size
)
2873 const char *name
= adapter
->driver_info
.name
;
2874 len
= min(strlen(name
), identifier
->driver_size
- 1);
2875 memcpy(identifier
->driver
, name
, len
);
2876 identifier
->driver
[len
] = '\0';
2879 if (identifier
->description_size
)
2881 const char *description
= adapter
->driver_info
.description
;
2882 len
= min(strlen(description
), identifier
->description_size
- 1);
2883 memcpy(identifier
->description
, description
, len
);
2884 identifier
->description
[len
] = '\0';
2887 /* Note that d3d8 doesn't supply a device name. */
2888 if (identifier
->device_name_size
)
2890 static const char *device_name
= "\\\\.\\DISPLAY1"; /* FIXME: May depend on desktop? */
2892 len
= strlen(device_name
);
2893 if (len
>= identifier
->device_name_size
)
2895 ERR("Device name size too small.\n");
2896 return WINED3DERR_INVALIDCALL
;
2899 memcpy(identifier
->device_name
, device_name
, len
);
2900 identifier
->device_name
[len
] = '\0';
2903 identifier
->driver_version
.u
.HighPart
= adapter
->driver_info
.version_high
;
2904 identifier
->driver_version
.u
.LowPart
= adapter
->driver_info
.version_low
;
2905 identifier
->vendor_id
= adapter
->driver_info
.vendor
;
2906 identifier
->device_id
= adapter
->driver_info
.device
;
2907 identifier
->subsystem_id
= 0;
2908 identifier
->revision
= 0;
2909 memcpy(&identifier
->device_identifier
, &IID_D3DDEVICE_D3DUID
, sizeof(identifier
->device_identifier
));
2910 identifier
->whql_level
= (flags
& WINED3DENUM_NO_WHQL_LEVEL
) ? 0 : 1;
2911 memcpy(&identifier
->adapter_luid
, &adapter
->luid
, sizeof(identifier
->adapter_luid
));
2912 identifier
->video_memory
= adapter
->TextureRam
;
2917 static BOOL
IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(const struct wined3d_gl_info
*gl_info
,
2918 const WineD3D_PixelFormat
*cfg
, const struct wined3d_format
*format
)
2920 short redSize
, greenSize
, blueSize
, alphaSize
, colorBits
;
2925 /* Float formats need FBOs. If FBOs are used this function isn't called */
2926 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
2928 if(cfg
->iPixelType
== WGL_TYPE_RGBA_ARB
) { /* Integer RGBA formats */
2929 if (!getColorBits(format
, &redSize
, &greenSize
, &blueSize
, &alphaSize
, &colorBits
))
2931 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
2935 if(cfg
->redSize
< redSize
)
2938 if(cfg
->greenSize
< greenSize
)
2941 if(cfg
->blueSize
< blueSize
)
2944 if(cfg
->alphaSize
< alphaSize
)
2950 /* Probably a RGBA_float or color index mode */
2954 static BOOL
IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(const struct wined3d_gl_info
*gl_info
,
2955 const WineD3D_PixelFormat
*cfg
, const struct wined3d_format
*format
)
2957 short depthSize
, stencilSize
;
2958 BOOL lockable
= FALSE
;
2963 if (!getDepthStencilBits(format
, &depthSize
, &stencilSize
))
2965 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
2969 /* Float formats need FBOs. If FBOs are used this function isn't called */
2970 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
2972 if ((format
->id
== WINED3DFMT_D16_LOCKABLE
) || (format
->id
== WINED3DFMT_D32_FLOAT
))
2975 /* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports.
2976 * We can safely report 'compatible' formats (e.g. D24 can be used for D16) as long as we aren't dealing with
2977 * a lockable format. This also helps D3D <= 7 as they expect D16 which isn't offered without this on Geforce8 cards. */
2978 if(!(cfg
->depthSize
== depthSize
|| (!lockable
&& cfg
->depthSize
> depthSize
)))
2981 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
2982 * allow more stencil bits than requested. */
2983 if(cfg
->stencilSize
< stencilSize
)
2989 HRESULT CDECL
wined3d_check_depth_stencil_match(const struct wined3d
*wined3d
,
2990 UINT adapter_idx
, WINED3DDEVTYPE device_type
, enum wined3d_format_id adapter_format_id
,
2991 enum wined3d_format_id render_target_format_id
, enum wined3d_format_id depth_stencil_format_id
)
2993 const struct wined3d_format
*rt_format
;
2994 const struct wined3d_format
*ds_format
;
2995 const struct wined3d_adapter
*adapter
;
2997 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s,\n"
2998 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
2999 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3000 debug_d3dformat(render_target_format_id
), debug_d3dformat(depth_stencil_format_id
));
3002 if (adapter_idx
>= wined3d
->adapter_count
)
3003 return WINED3DERR_INVALIDCALL
;
3005 adapter
= &wined3d
->adapters
[adapter_idx
];
3006 rt_format
= wined3d_get_format(&adapter
->gl_info
, render_target_format_id
);
3007 ds_format
= wined3d_get_format(&adapter
->gl_info
, depth_stencil_format_id
);
3008 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3010 if ((rt_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)
3011 && (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)))
3013 TRACE_(d3d_caps
)("Formats match.\n");
3019 const WineD3D_PixelFormat
*cfgs
;
3020 unsigned int cfg_count
;
3023 cfgs
= adapter
->cfgs
;
3024 cfg_count
= adapter
->nCfgs
;
3025 for (i
= 0; i
< cfg_count
; ++i
)
3027 if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter
->gl_info
, &cfgs
[i
], rt_format
))
3029 if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter
->gl_info
, &cfgs
[i
], ds_format
))
3031 TRACE_(d3d_caps
)("Formats match.\n");
3038 TRACE_(d3d_caps
)("Unsupported format pair: %s and %s.\n",
3039 debug_d3dformat(render_target_format_id
),
3040 debug_d3dformat(depth_stencil_format_id
));
3042 return WINED3DERR_NOTAVAILABLE
;
3045 HRESULT CDECL
wined3d_check_device_multisample_type(const struct wined3d
*wined3d
, UINT adapter_idx
,
3046 WINED3DDEVTYPE device_type
, enum wined3d_format_id surface_format_id
, BOOL windowed
,
3047 WINED3DMULTISAMPLE_TYPE multisample_type
, DWORD
*quality_levels
)
3049 const struct wined3d_adapter
*adapter
;
3050 const struct wined3d_format
*format
;
3052 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, surface_format %s,\n"
3053 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
3054 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(surface_format_id
),
3055 windowed
, multisample_type
, quality_levels
);
3057 if (adapter_idx
>= wined3d
->adapter_count
)
3058 return WINED3DERR_INVALIDCALL
;
3060 /* TODO: Handle windowed, add more quality levels. */
3062 if (WINED3DMULTISAMPLE_NONE
== multisample_type
)
3064 if (quality_levels
) *quality_levels
= 1;
3068 /* By default multisampling is disabled right now as it causes issues
3069 * on some Nvidia driver versions and it doesn't work well in combination
3071 if (!wined3d_settings
.allow_multisampling
)
3072 return WINED3DERR_NOTAVAILABLE
;
3074 adapter
= &wined3d
->adapters
[adapter_idx
];
3075 format
= wined3d_get_format(&adapter
->gl_info
, surface_format_id
);
3076 if (!format
) return WINED3DERR_INVALIDCALL
;
3078 if (format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
))
3080 const WineD3D_PixelFormat
*cfgs
;
3081 unsigned int i
, cfg_count
;
3083 cfgs
= adapter
->cfgs
;
3084 cfg_count
= adapter
->nCfgs
;
3085 for (i
= 0; i
< cfg_count
; ++i
)
3087 if(cfgs
[i
].numSamples
!= multisample_type
)
3090 if (!IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter
->gl_info
, &cfgs
[i
], format
))
3093 TRACE("Found pixel format %u to support multisample_type %#x for format %s.\n",
3094 cfgs
[i
].iPixelFormat
, multisample_type
, debug_d3dformat(surface_format_id
));
3096 if (quality_levels
) *quality_levels
= 1;
3101 else if (format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)
3103 short redSize
, greenSize
, blueSize
, alphaSize
, colorBits
;
3104 const WineD3D_PixelFormat
*cfgs
;
3105 unsigned int i
, cfg_count
;
3107 if (!getColorBits(format
, &redSize
, &greenSize
, &blueSize
, &alphaSize
, &colorBits
))
3109 ERR("Unable to get color bits for format %s, can't check multisampling capability.\n",
3110 debug_d3dformat(surface_format_id
));
3111 return WINED3DERR_NOTAVAILABLE
;
3114 cfgs
= adapter
->cfgs
;
3115 cfg_count
= adapter
->nCfgs
;
3116 for (i
= 0; i
< cfg_count
; ++i
)
3118 if(cfgs
[i
].numSamples
!= multisample_type
)
3120 if(cfgs
[i
].redSize
!= redSize
)
3122 if(cfgs
[i
].greenSize
!= greenSize
)
3124 if(cfgs
[i
].blueSize
!= blueSize
)
3126 /* Not all drivers report alpha-less formats since they use 32-bit
3127 * anyway, so accept alpha even if we didn't ask for it. */
3128 if(alphaSize
&& cfgs
[i
].alphaSize
!= alphaSize
)
3130 if (cfgs
[i
].colorSize
!= (format
->byte_count
<< 3))
3133 TRACE("Found pixel format %u to support multisample_type %#x for format %s.\n",
3134 cfgs
[i
].iPixelFormat
, multisample_type
, debug_d3dformat(surface_format_id
));
3136 if (quality_levels
) *quality_levels
= 1;
3141 return WINED3DERR_NOTAVAILABLE
;
3144 /* Check if we support bumpmapping for a format */
3145 static BOOL
CheckBumpMapCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3147 /* Ask the fixed function pipeline implementation if it can deal
3148 * with the conversion. If we've got a GL extension giving native
3149 * support this will be an identity conversion. */
3150 return (format
->flags
& WINED3DFMT_FLAG_BUMPMAP
)
3151 && adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
);
3154 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
3155 static BOOL
CheckDepthStencilCapability(const struct wined3d_adapter
*adapter
,
3156 const struct wined3d_format
*display_format
, const struct wined3d_format
*ds_format
)
3160 /* Only allow depth/stencil formats */
3161 if (!(ds_format
->depth_size
|| ds_format
->stencil_size
)) return FALSE
;
3163 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3165 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
3166 if (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)) return TRUE
;
3170 /* Walk through all WGL pixel formats to find a match */
3171 for (it
= 0; it
< adapter
->nCfgs
; ++it
)
3173 WineD3D_PixelFormat
*cfg
= &adapter
->cfgs
[it
];
3174 if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter
->gl_info
, cfg
, display_format
))
3176 if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter
->gl_info
, cfg
, ds_format
))
3187 static BOOL
CheckFilterCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3189 /* The flags entry of a format contains the filtering capability */
3190 if (format
->flags
& WINED3DFMT_FLAG_FILTERING
) return TRUE
;
3195 /* Check the render target capabilities of a format */
3196 static BOOL
CheckRenderTargetCapability(const struct wined3d_adapter
*adapter
,
3197 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*check_format
)
3199 /* Filter out non-RT formats */
3200 if (!(check_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)) return FALSE
;
3201 if (wined3d_settings
.offscreen_rendering_mode
== ORM_BACKBUFFER
)
3203 WineD3D_PixelFormat
*cfgs
= adapter
->cfgs
;
3205 short AdapterRed
, AdapterGreen
, AdapterBlue
, AdapterAlpha
, AdapterTotalSize
;
3206 short CheckRed
, CheckGreen
, CheckBlue
, CheckAlpha
, CheckTotalSize
;
3208 getColorBits(adapter_format
, &AdapterRed
, &AdapterGreen
, &AdapterBlue
, &AdapterAlpha
, &AdapterTotalSize
);
3209 getColorBits(check_format
, &CheckRed
, &CheckGreen
, &CheckBlue
, &CheckAlpha
, &CheckTotalSize
);
3211 /* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
3212 * The format must match in RGB, alpha is allowed to be different. (Only the backbuffer can have alpha) */
3213 if(!((AdapterRed
== CheckRed
) && (AdapterGreen
== CheckGreen
) && (AdapterBlue
== CheckBlue
))) {
3214 TRACE_(d3d_caps
)("[FAILED]\n");
3218 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
3219 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
3220 for (it
= 0; it
< adapter
->nCfgs
; ++it
)
3222 if (cfgs
[it
].windowDrawable
&& IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter
->gl_info
,
3223 &cfgs
[it
], check_format
))
3225 TRACE_(d3d_caps
)("Pixel format %d is compatible with format %s.\n",
3226 cfgs
[it
].iPixelFormat
, debug_d3dformat(check_format
->id
));
3231 else if(wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3233 /* For now return TRUE for FBOs until we have some proper checks.
3234 * Note that this function will only be called when the format is around for texturing. */
3240 static BOOL
CheckSrgbReadCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3242 return format
->flags
& WINED3DFMT_FLAG_SRGB_READ
;
3245 static BOOL
CheckSrgbWriteCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3247 /* Only offer SRGB writing on X8R8G8B8/A8R8G8B8 when we use ARB or GLSL shaders as we are
3248 * doing the color fixup in shaders.
3249 * Note Windows drivers (at least on the Geforce 8800) also offer this on R5G6B5. */
3250 if (format
->flags
& WINED3DFMT_FLAG_SRGB_WRITE
)
3252 int vs_selected_mode
;
3253 int ps_selected_mode
;
3254 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
3256 if((ps_selected_mode
== SHADER_ARB
) || (ps_selected_mode
== SHADER_GLSL
)) {
3257 TRACE_(d3d_caps
)("[OK]\n");
3262 TRACE_(d3d_caps
)("[FAILED] - sRGB writes not supported by format %s.\n", debug_d3dformat(format
->id
));
3266 /* Check if a format support blending in combination with pixel shaders */
3267 static BOOL
CheckPostPixelShaderBlendingCapability(const struct wined3d_adapter
*adapter
,
3268 const struct wined3d_format
*format
)
3270 /* The flags entry of a format contains the post pixel shader blending capability */
3271 if (format
->flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
) return TRUE
;
3276 static BOOL
CheckWrapAndMipCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3278 /* OpenGL supports mipmapping on all formats basically. Wrapping is unsupported,
3279 * but we have to report mipmapping so we cannot reject this flag. Tests show that
3280 * windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to show
3281 * that wrapping is supported. The lack of filtering will sort out the mipmapping
3282 * capability anyway.
3284 * For now lets report this on all formats, but in the future we may want to
3285 * restrict it to some should games need that
3290 /* Check if a texture format is supported on the given adapter */
3291 static BOOL
CheckTextureCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3293 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3298 * supported: RGB(A) formats
3300 case WINED3DFMT_B8G8R8_UNORM
: /* Enable for dx7, blacklisted for 8 and 9 above */
3301 case WINED3DFMT_B8G8R8A8_UNORM
:
3302 case WINED3DFMT_B8G8R8X8_UNORM
:
3303 case WINED3DFMT_B5G6R5_UNORM
:
3304 case WINED3DFMT_B5G5R5X1_UNORM
:
3305 case WINED3DFMT_B5G5R5A1_UNORM
:
3306 case WINED3DFMT_B4G4R4A4_UNORM
:
3307 case WINED3DFMT_A8_UNORM
:
3308 case WINED3DFMT_B4G4R4X4_UNORM
:
3309 case WINED3DFMT_R8G8B8A8_UNORM
:
3310 case WINED3DFMT_R8G8B8X8_UNORM
:
3311 case WINED3DFMT_B10G10R10A2_UNORM
:
3312 case WINED3DFMT_R10G10B10A2_UNORM
:
3313 case WINED3DFMT_R16G16_UNORM
:
3314 TRACE_(d3d_caps
)("[OK]\n");
3317 case WINED3DFMT_B2G3R3_UNORM
:
3318 TRACE_(d3d_caps
)("[FAILED] - Not supported on Windows\n");
3322 * Not supported: Palettized
3323 * Only some Geforce/Voodoo3/G400 cards offer 8-bit textures in case of <=Direct3D7.
3324 * Since it is not widely available, don't offer it. Further no Windows driver offers
3325 * WINED3DFMT_P8_UINT_A8_NORM, so don't offer it either.
3327 case WINED3DFMT_P8_UINT
:
3328 case WINED3DFMT_P8_UINT_A8_UNORM
:
3332 * Supported: (Alpha)-Luminance
3334 case WINED3DFMT_L8_UNORM
:
3335 case WINED3DFMT_L8A8_UNORM
:
3336 case WINED3DFMT_L16_UNORM
:
3337 TRACE_(d3d_caps
)("[OK]\n");
3340 /* Not supported on Windows, thus disabled */
3341 case WINED3DFMT_L4A4_UNORM
:
3342 TRACE_(d3d_caps
)("[FAILED] - not supported on windows\n");
3346 * Supported: Depth/Stencil formats
3348 case WINED3DFMT_D16_LOCKABLE
:
3349 case WINED3DFMT_D16_UNORM
:
3350 case WINED3DFMT_S1_UINT_D15_UNORM
:
3351 case WINED3DFMT_X8D24_UNORM
:
3352 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
3353 case WINED3DFMT_D24_UNORM_S8_UINT
:
3354 case WINED3DFMT_S8_UINT_D24_FLOAT
:
3355 case WINED3DFMT_D32_UNORM
:
3356 case WINED3DFMT_D32_FLOAT
:
3359 case WINED3DFMT_INTZ
:
3360 if (gl_info
->supported
[EXT_PACKED_DEPTH_STENCIL
]
3361 || gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3366 * Not supported everywhere(depends on GL_ATI_envmap_bumpmap or
3367 * GL_NV_texture_shader). Emulated by shaders
3369 case WINED3DFMT_R8G8_SNORM
:
3370 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
3371 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
3372 case WINED3DFMT_R8G8B8A8_SNORM
:
3373 case WINED3DFMT_R16G16_SNORM
:
3374 /* Ask the shader backend if it can deal with the conversion. If
3375 * we've got a GL extension giving native support this will be an
3376 * identity conversion. */
3377 if (adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
))
3379 TRACE_(d3d_caps
)("[OK]\n");
3382 TRACE_(d3d_caps
)("[FAILED]\n");
3385 case WINED3DFMT_DXT1
:
3386 case WINED3DFMT_DXT2
:
3387 case WINED3DFMT_DXT3
:
3388 case WINED3DFMT_DXT4
:
3389 case WINED3DFMT_DXT5
:
3390 if (gl_info
->supported
[EXT_TEXTURE_COMPRESSION_S3TC
])
3392 TRACE_(d3d_caps
)("[OK]\n");
3395 TRACE_(d3d_caps
)("[FAILED]\n");
3400 * Odd formats - not supported
3402 case WINED3DFMT_VERTEXDATA
:
3403 case WINED3DFMT_R16_UINT
:
3404 case WINED3DFMT_R32_UINT
:
3405 case WINED3DFMT_R16G16B16A16_SNORM
:
3406 case WINED3DFMT_R10G10B10_SNORM_A2_UNORM
:
3407 case WINED3DFMT_R10G11B11_SNORM
:
3408 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3412 * WINED3DFMT_R8G8_SNORM_Cx: Not supported right now
3414 case WINED3DFMT_R8G8_SNORM_Cx
:
3415 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3419 case WINED3DFMT_UYVY
:
3420 case WINED3DFMT_YUY2
:
3421 if (gl_info
->supported
[APPLE_YCBCR_422
])
3423 TRACE_(d3d_caps
)("[OK]\n");
3426 TRACE_(d3d_caps
)("[FAILED]\n");
3428 case WINED3DFMT_YV12
:
3429 TRACE_(d3d_caps
)("[FAILED]\n");
3433 case WINED3DFMT_R16G16B16A16_UNORM
:
3434 case WINED3DFMT_B2G3R3A8_UNORM
:
3435 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3438 /* Floating point formats */
3439 case WINED3DFMT_R16_FLOAT
:
3440 case WINED3DFMT_R16G16_FLOAT
:
3441 case WINED3DFMT_R16G16B16A16_FLOAT
:
3442 if (gl_info
->supported
[ARB_TEXTURE_FLOAT
] && gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
3444 TRACE_(d3d_caps
)("[OK]\n");
3447 TRACE_(d3d_caps
)("[FAILED]\n");
3450 case WINED3DFMT_R32_FLOAT
:
3451 case WINED3DFMT_R32G32_FLOAT
:
3452 case WINED3DFMT_R32G32B32A32_FLOAT
:
3453 if (gl_info
->supported
[ARB_TEXTURE_FLOAT
])
3455 TRACE_(d3d_caps
)("[OK]\n");
3458 TRACE_(d3d_caps
)("[FAILED]\n");
3461 /* ATI instancing hack: Although ATI cards do not support Shader Model 3.0, they support
3462 * instancing. To query if the card supports instancing CheckDeviceFormat with the special format
3463 * MAKEFOURCC('I','N','S','T') is used. Should a (broken) app check for this provide a proper return value.
3464 * We can do instancing with all shader versions, but we need vertex shaders.
3466 * Additionally applications have to set the D3DRS_POINTSIZE render state to MAKEFOURCC('I','N','S','T') once
3467 * to enable instancing. WineD3D doesn't need that and just ignores it.
3469 * With Shader Model 3.0 capable cards Instancing 'just works' in Windows.
3471 case WINED3DFMT_INST
:
3472 TRACE("ATI Instancing check hack\n");
3473 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
] || gl_info
->supported
[ARB_VERTEX_SHADER
])
3475 TRACE_(d3d_caps
)("[OK]\n");
3478 TRACE_(d3d_caps
)("[FAILED]\n");
3481 /* Some weird FOURCC formats */
3482 case WINED3DFMT_R8G8_B8G8
:
3483 case WINED3DFMT_G8R8_G8B8
:
3484 case WINED3DFMT_MULTI2_ARGB8
:
3485 TRACE_(d3d_caps
)("[FAILED]\n");
3488 /* Vendor specific formats */
3489 case WINED3DFMT_ATI2N
:
3490 if (gl_info
->supported
[ATI_TEXTURE_COMPRESSION_3DC
]
3491 || gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
])
3493 if (adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
)
3494 && adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
))
3496 TRACE_(d3d_caps
)("[OK]\n");
3500 TRACE_(d3d_caps
)("[OK]\n");
3503 TRACE_(d3d_caps
)("[FAILED]\n");
3506 /* Depth bound test. To query if the card supports it CheckDeviceFormat with the special
3507 * format MAKEFOURCC('N','V','D','B') is used.
3508 * It is enabled by setting D3DRS_ADAPTIVETESS_X render state to MAKEFOURCC('N','V','D','B') and
3509 * then controlled by setting D3DRS_ADAPTIVETESS_Z (zMin) and D3DRS_ADAPTIVETESS_W (zMax)
3512 case WINED3DFMT_NVDB
:
3513 if (gl_info
->supported
[EXT_DEPTH_BOUNDS_TEST
])
3515 TRACE_(d3d_caps
)("[OK]\n");
3518 TRACE_(d3d_caps
)("[FAILED]\n");
3521 case WINED3DFMT_NVHU
:
3522 case WINED3DFMT_NVHS
:
3523 /* These formats seem to be similar to the HILO formats in GL_NV_texture_shader. NVHU
3524 * is said to be GL_UNSIGNED_HILO16, NVHS GL_SIGNED_HILO16. Rumours say that d3d computes
3525 * a 3rd channel similarly to D3DFMT_CxV8U8(So NVHS could be called D3DFMT_CxV16U16).
3526 * ATI refused to support formats which can easilly be emulated with pixel shaders, so
3527 * Applications have to deal with not having NVHS and NVHU.
3529 TRACE_(d3d_caps
)("[FAILED]\n");
3532 case WINED3DFMT_NULL
:
3533 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3537 case WINED3DFMT_UNKNOWN
:
3541 ERR("Unhandled format %s.\n", debug_d3dformat(format
->id
));
3547 static BOOL
CheckSurfaceCapability(const struct wined3d_adapter
*adapter
,
3548 const struct wined3d_format
*adapter_format
,
3549 const struct wined3d_format
*check_format
,
3550 WINED3DSURFTYPE SurfaceType
)
3552 if (SurfaceType
== SURFACE_GDI
)
3554 switch (check_format
->id
)
3556 case WINED3DFMT_B8G8R8_UNORM
:
3557 case WINED3DFMT_B8G8R8A8_UNORM
:
3558 case WINED3DFMT_B8G8R8X8_UNORM
:
3559 case WINED3DFMT_B5G6R5_UNORM
:
3560 case WINED3DFMT_B5G5R5X1_UNORM
:
3561 case WINED3DFMT_B5G5R5A1_UNORM
:
3562 case WINED3DFMT_B4G4R4A4_UNORM
:
3563 case WINED3DFMT_B2G3R3_UNORM
:
3564 case WINED3DFMT_A8_UNORM
:
3565 case WINED3DFMT_B2G3R3A8_UNORM
:
3566 case WINED3DFMT_B4G4R4X4_UNORM
:
3567 case WINED3DFMT_R10G10B10A2_UNORM
:
3568 case WINED3DFMT_R8G8B8A8_UNORM
:
3569 case WINED3DFMT_R8G8B8X8_UNORM
:
3570 case WINED3DFMT_R16G16_UNORM
:
3571 case WINED3DFMT_B10G10R10A2_UNORM
:
3572 case WINED3DFMT_R16G16B16A16_UNORM
:
3573 case WINED3DFMT_P8_UINT
:
3574 TRACE_(d3d_caps
)("[OK]\n");
3577 TRACE_(d3d_caps
)("[FAILED] - not available on GDI surfaces\n");
3582 /* All format that are supported for textures are supported for surfaces as well */
3583 if (CheckTextureCapability(adapter
, check_format
)) return TRUE
;
3584 /* All depth stencil formats are supported on surfaces */
3585 if (CheckDepthStencilCapability(adapter
, adapter_format
, check_format
)) return TRUE
;
3587 /* If opengl can't process the format natively, the blitter may be able to convert it */
3588 if (adapter
->blitter
->blit_supported(&adapter
->gl_info
, BLIT_OP_BLIT
,
3589 NULL
, WINED3DPOOL_DEFAULT
, 0, check_format
,
3590 NULL
, WINED3DPOOL_DEFAULT
, 0, adapter_format
))
3592 TRACE_(d3d_caps
)("[OK]\n");
3596 /* Reject other formats */
3597 TRACE_(d3d_caps
)("[FAILED]\n");
3601 static BOOL
CheckVertexTextureCapability(const struct wined3d_adapter
*adapter
,
3602 const struct wined3d_format
*format
)
3604 return adapter
->gl_info
.limits
.vertex_samplers
&& (format
->flags
& WINED3DFMT_FLAG_VTF
);
3607 HRESULT CDECL
wined3d_check_device_format(const struct wined3d
*wined3d
, UINT adapter_idx
,
3608 WINED3DDEVTYPE device_type
, enum wined3d_format_id adapter_format_id
, DWORD usage
,
3609 WINED3DRESOURCETYPE resource_type
, enum wined3d_format_id check_format_id
, WINED3DSURFTYPE surface_type
)
3611 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
3612 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3613 const struct wined3d_format
*adapter_format
= wined3d_get_format(gl_info
, adapter_format_id
);
3614 const struct wined3d_format
*format
= wined3d_get_format(gl_info
, check_format_id
);
3615 DWORD usage_caps
= 0;
3617 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s,\n"
3618 "resource_type %s, check_format %s, surface_type %#x.\n",
3619 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3620 debug_d3dusage(usage
), debug_d3dusagequery(usage
), debug_d3dresourcetype(resource_type
),
3621 debug_d3dformat(check_format_id
), surface_type
);
3623 if (adapter_idx
>= wined3d
->adapter_count
)
3624 return WINED3DERR_INVALIDCALL
;
3626 switch (resource_type
)
3628 case WINED3DRTYPE_CUBETEXTURE
:
3629 /* Cubetexture allows:
3630 * - WINED3DUSAGE_AUTOGENMIPMAP
3631 * - WINED3DUSAGE_DEPTHSTENCIL
3632 * - WINED3DUSAGE_DYNAMIC
3633 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3634 * - WINED3DUSAGE_RENDERTARGET
3635 * - WINED3DUSAGE_SOFTWAREPROCESSING
3636 * - WINED3DUSAGE_QUERY_WRAPANDMIP
3638 if (surface_type
!= SURFACE_OPENGL
)
3640 TRACE_(d3d_caps
)("[FAILED]\n");
3641 return WINED3DERR_NOTAVAILABLE
;
3644 if (!gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3646 TRACE_(d3d_caps
)("[FAILED] - No cube texture support\n");
3647 return WINED3DERR_NOTAVAILABLE
;
3650 if (!CheckTextureCapability(adapter
, format
))
3652 TRACE_(d3d_caps
)("[FAILED] - Cube texture format not supported\n");
3653 return WINED3DERR_NOTAVAILABLE
;
3656 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
3658 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
3659 /* When autogenmipmap isn't around continue and return
3660 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
3661 TRACE_(d3d_caps
)("[FAILED] - No autogenmipmap support, but continuing\n");
3663 usage_caps
|= WINED3DUSAGE_AUTOGENMIPMAP
;
3666 /* Always report dynamic locking. */
3667 if (usage
& WINED3DUSAGE_DYNAMIC
)
3668 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
3670 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3672 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3674 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3675 return WINED3DERR_NOTAVAILABLE
;
3677 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3680 /* Always report software processing. */
3681 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
3682 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
3684 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
3686 if (!CheckFilterCapability(adapter
, format
))
3688 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
3689 return WINED3DERR_NOTAVAILABLE
;
3691 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
3694 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3696 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3698 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3699 return WINED3DERR_NOTAVAILABLE
;
3701 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3704 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
3706 if (!CheckSrgbReadCapability(adapter
, format
))
3708 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
3709 return WINED3DERR_NOTAVAILABLE
;
3711 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
3714 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
3716 if (!CheckSrgbWriteCapability(adapter
, format
))
3718 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
3719 return WINED3DERR_NOTAVAILABLE
;
3721 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
3724 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
3726 if (!CheckVertexTextureCapability(adapter
, format
))
3728 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
3729 return WINED3DERR_NOTAVAILABLE
;
3731 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
3734 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
3736 if (!CheckWrapAndMipCapability(adapter
, format
))
3738 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
3739 return WINED3DERR_NOTAVAILABLE
;
3741 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
3745 case WINED3DRTYPE_SURFACE
:
3747 * - WINED3DUSAGE_DEPTHSTENCIL
3748 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3749 * - WINED3DUSAGE_RENDERTARGET
3751 if (!CheckSurfaceCapability(adapter
, adapter_format
, format
, surface_type
))
3753 TRACE_(d3d_caps
)("[FAILED] - Not supported for plain surfaces\n");
3754 return WINED3DERR_NOTAVAILABLE
;
3757 if (usage
& WINED3DUSAGE_DEPTHSTENCIL
)
3759 if (!CheckDepthStencilCapability(adapter
, adapter_format
, format
))
3761 TRACE_(d3d_caps
)("[FAILED] - No depthstencil support\n");
3762 return WINED3DERR_NOTAVAILABLE
;
3764 usage_caps
|= WINED3DUSAGE_DEPTHSTENCIL
;
3767 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3769 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3771 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3772 return WINED3DERR_NOTAVAILABLE
;
3774 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3777 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3779 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3781 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3782 return WINED3DERR_NOTAVAILABLE
;
3784 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3788 case WINED3DRTYPE_TEXTURE
:
3790 * - WINED3DUSAGE_AUTOGENMIPMAP
3791 * - WINED3DUSAGE_DEPTHSTENCIL
3792 * - WINED3DUSAGE_DMAP
3793 * - WINED3DUSAGE_DYNAMIC
3794 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3795 * - WINED3DUSAGE_RENDERTARGET
3796 * - WINED3DUSAGE_SOFTWAREPROCESSING
3797 * - WINED3DUSAGE_TEXTAPI (d3d9ex)
3798 * - WINED3DUSAGE_QUERY_WRAPANDMIP
3800 if (surface_type
!= SURFACE_OPENGL
)
3802 TRACE_(d3d_caps
)("[FAILED]\n");
3803 return WINED3DERR_NOTAVAILABLE
;
3806 if (!CheckTextureCapability(adapter
, format
))
3808 TRACE_(d3d_caps
)("[FAILED] - Texture format not supported\n");
3809 return WINED3DERR_NOTAVAILABLE
;
3812 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
3814 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
3815 /* When autogenmipmap isn't around continue and return
3816 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
3817 TRACE_(d3d_caps
)("[FAILED] - No autogenmipmap support, but continuing\n");
3819 usage_caps
|= WINED3DUSAGE_AUTOGENMIPMAP
;
3822 /* Always report dynamic locking. */
3823 if (usage
& WINED3DUSAGE_DYNAMIC
)
3824 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
3826 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3828 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3830 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3831 return WINED3DERR_NOTAVAILABLE
;
3833 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3836 /* Always report software processing. */
3837 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
3838 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
3840 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
3842 if (!CheckFilterCapability(adapter
, format
))
3844 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
3845 return WINED3DERR_NOTAVAILABLE
;
3847 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
3850 if (usage
& WINED3DUSAGE_QUERY_LEGACYBUMPMAP
)
3852 if (!CheckBumpMapCapability(adapter
, format
))
3854 TRACE_(d3d_caps
)("[FAILED] - No legacy bumpmap support\n");
3855 return WINED3DERR_NOTAVAILABLE
;
3857 usage_caps
|= WINED3DUSAGE_QUERY_LEGACYBUMPMAP
;
3860 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3862 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3864 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3865 return WINED3DERR_NOTAVAILABLE
;
3867 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3870 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
3872 if (!CheckSrgbReadCapability(adapter
, format
))
3874 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
3875 return WINED3DERR_NOTAVAILABLE
;
3877 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
3880 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
3882 if (!CheckSrgbWriteCapability(adapter
, format
))
3884 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
3885 return WINED3DERR_NOTAVAILABLE
;
3887 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
3890 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
3892 if (!CheckVertexTextureCapability(adapter
, format
))
3894 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
3895 return WINED3DERR_NOTAVAILABLE
;
3897 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
3900 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
3902 if (!CheckWrapAndMipCapability(adapter
, format
))
3904 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
3905 return WINED3DERR_NOTAVAILABLE
;
3907 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
3910 if (usage
& WINED3DUSAGE_DEPTHSTENCIL
)
3912 if (!CheckDepthStencilCapability(adapter
, adapter_format
, format
))
3914 TRACE_(d3d_caps
)("[FAILED] - No depth stencil support\n");
3915 return WINED3DERR_NOTAVAILABLE
;
3917 if ((format
->flags
& WINED3DFMT_FLAG_SHADOW
) && !gl_info
->supported
[ARB_SHADOW
])
3919 TRACE_(d3d_caps
)("[FAILED] - No shadow sampler support.\n");
3920 return WINED3DERR_NOTAVAILABLE
;
3922 usage_caps
|= WINED3DUSAGE_DEPTHSTENCIL
;
3926 case WINED3DRTYPE_VOLUMETEXTURE
:
3927 case WINED3DRTYPE_VOLUME
:
3928 /* Volume is to VolumeTexture what Surface is to Texture, but its
3929 * usage caps are not documented. Most driver seem to offer
3930 * (nearly) the same on Volume and VolumeTexture, so do that too.
3932 * Volumetexture allows:
3933 * - D3DUSAGE_DYNAMIC
3934 * - D3DUSAGE_NONSECURE (d3d9ex)
3935 * - D3DUSAGE_SOFTWAREPROCESSING
3936 * - D3DUSAGE_QUERY_WRAPANDMIP
3938 if (surface_type
!= SURFACE_OPENGL
)
3940 TRACE_(d3d_caps
)("[FAILED]\n");
3941 return WINED3DERR_NOTAVAILABLE
;
3944 if (!gl_info
->supported
[EXT_TEXTURE3D
])
3946 TRACE_(d3d_caps
)("[FAILED] - No volume texture support\n");
3947 return WINED3DERR_NOTAVAILABLE
;
3950 if (!CheckTextureCapability(adapter
, format
))
3952 TRACE_(d3d_caps
)("[FAILED] - Format not supported\n");
3953 return WINED3DERR_NOTAVAILABLE
;
3956 /* Filter formats that need conversion; For one part, this
3957 * conversion is unimplemented, and volume textures are huge, so
3958 * it would be a big performance hit. Unless we hit an application
3959 * needing one of those formats, don't advertize them to avoid
3960 * leading applications into temptation. The windows drivers don't
3961 * support most of those formats on volumes anyway, except for
3962 * WINED3DFMT_R32_FLOAT. */
3963 switch (check_format_id
)
3965 case WINED3DFMT_P8_UINT
:
3966 case WINED3DFMT_L4A4_UNORM
:
3967 case WINED3DFMT_R32_FLOAT
:
3968 case WINED3DFMT_R16_FLOAT
:
3969 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
3970 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
3971 case WINED3DFMT_R16G16_UNORM
:
3972 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
3973 return WINED3DERR_NOTAVAILABLE
;
3975 case WINED3DFMT_R8G8B8A8_SNORM
:
3976 case WINED3DFMT_R16G16_SNORM
:
3977 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
3979 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
3980 return WINED3DERR_NOTAVAILABLE
;
3984 case WINED3DFMT_R8G8_SNORM
:
3985 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
3987 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
3988 return WINED3DERR_NOTAVAILABLE
;
3992 case WINED3DFMT_DXT1
:
3993 case WINED3DFMT_DXT2
:
3994 case WINED3DFMT_DXT3
:
3995 case WINED3DFMT_DXT4
:
3996 case WINED3DFMT_DXT5
:
3997 /* The GL_EXT_texture_compression_s3tc spec requires that
3998 * loading an s3tc compressed texture results in an error.
3999 * While the D3D refrast does support s3tc volumes, at
4000 * least the nvidia windows driver does not, so we're free
4001 * not to support this format. */
4002 TRACE_(d3d_caps
)("[FAILED] - DXTn does not support 3D textures\n");
4003 return WINED3DERR_NOTAVAILABLE
;
4006 /* Do nothing, continue with checking the format below */
4010 /* Always report dynamic locking. */
4011 if (usage
& WINED3DUSAGE_DYNAMIC
)
4012 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
4014 /* Always report software processing. */
4015 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
4016 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
4018 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
4020 if (!CheckFilterCapability(adapter
, format
))
4022 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
4023 return WINED3DERR_NOTAVAILABLE
;
4025 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
4028 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
4030 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
4032 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
4033 return WINED3DERR_NOTAVAILABLE
;
4035 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
4038 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
4040 if (!CheckSrgbReadCapability(adapter
, format
))
4042 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
4043 return WINED3DERR_NOTAVAILABLE
;
4045 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
4048 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
4050 if (!CheckSrgbWriteCapability(adapter
, format
))
4052 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
4053 return WINED3DERR_NOTAVAILABLE
;
4055 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
4058 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
4060 if (!CheckVertexTextureCapability(adapter
, format
))
4062 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
4063 return WINED3DERR_NOTAVAILABLE
;
4065 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
4068 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
4070 if (!CheckWrapAndMipCapability(adapter
, format
))
4072 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
4073 return WINED3DERR_NOTAVAILABLE
;
4075 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
4080 FIXME_(d3d_caps
)("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type
));
4081 return WINED3DERR_NOTAVAILABLE
;
4084 /* When the usage_caps exactly matches usage return WINED3D_OK except for
4085 * the situation in which WINED3DUSAGE_AUTOGENMIPMAP isn't around, then
4086 * WINED3DOK_NOAUTOGEN is returned if all the other usage flags match. */
4087 if (usage_caps
== usage
)
4089 if (usage_caps
== (usage
& ~WINED3DUSAGE_AUTOGENMIPMAP
))
4090 return WINED3DOK_NOAUTOGEN
;
4092 TRACE_(d3d_caps
)("[FAILED] - Usage %#x requested for format %s and resource_type %s but only %#x is available.\n",
4093 usage
, debug_d3dformat(check_format_id
), debug_d3dresourcetype(resource_type
), usage_caps
);
4095 return WINED3DERR_NOTAVAILABLE
;
4098 HRESULT CDECL
wined3d_check_device_format_conversion(const struct wined3d
*wined3d
, UINT adapter_idx
,
4099 WINED3DDEVTYPE device_type
, enum wined3d_format_id src_format
, enum wined3d_format_id dst_format
)
4101 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
4102 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(src_format
),
4103 debug_d3dformat(dst_format
));
4108 HRESULT CDECL
wined3d_check_device_type(const struct wined3d
*wined3d
, UINT adapter_idx
, WINED3DDEVTYPE device_type
,
4109 enum wined3d_format_id display_format
, enum wined3d_format_id backbuffer_format
, BOOL windowed
)
4114 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
4115 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(display_format
),
4116 debug_d3dformat(backbuffer_format
), windowed
);
4118 if (adapter_idx
>= wined3d
->adapter_count
)
4119 return WINED3DERR_INVALIDCALL
;
4121 /* The task of this function is to check whether a certain display / backbuffer format
4122 * combination is available on the given adapter. In fullscreen mode microsoft specified
4123 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
4124 * and display format should match exactly.
4125 * In windowed mode format conversion can occur and this depends on the driver. When format
4126 * conversion is done, this function should nevertheless fail and applications need to use
4127 * CheckDeviceFormatConversion.
4128 * At the moment we assume that fullscreen and windowed have the same capabilities. */
4130 /* There are only 4 display formats. */
4131 if (!(display_format
== WINED3DFMT_B5G6R5_UNORM
4132 || display_format
== WINED3DFMT_B5G5R5X1_UNORM
4133 || display_format
== WINED3DFMT_B8G8R8X8_UNORM
4134 || display_format
== WINED3DFMT_B10G10R10A2_UNORM
))
4136 TRACE_(d3d_caps
)("Format %s is not supported as display format.\n", debug_d3dformat(display_format
));
4137 return WINED3DERR_NOTAVAILABLE
;
4140 /* If the requested display format is not available, don't continue. */
4141 mode_count
= wined3d_get_adapter_mode_count(wined3d
, adapter_idx
, display_format
);
4144 TRACE_(d3d_caps
)("No available modes for display format %s.\n", debug_d3dformat(display_format
));
4145 return WINED3DERR_NOTAVAILABLE
;
4148 /* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbuffer format,
4149 * it means 'reuse' the display format for the backbuffer. */
4150 if (!windowed
&& backbuffer_format
== WINED3DFMT_UNKNOWN
)
4152 TRACE_(d3d_caps
)("backbuffer_format WINED3FMT_UNKNOWN only available in windowed mode.\n");
4153 return WINED3DERR_NOTAVAILABLE
;
4156 /* In FULLSCREEN mode WINED3DFMT_B5G6R5_UNORM can only be mixed with
4157 * backbuffer format WINED3DFMT_B5G6R5_UNORM. */
4158 if (display_format
== WINED3DFMT_B5G6R5_UNORM
&& backbuffer_format
!= WINED3DFMT_B5G6R5_UNORM
)
4160 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4161 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4162 return WINED3DERR_NOTAVAILABLE
;
4165 /* In FULLSCREEN mode WINED3DFMT_B5G5R5X1_UNORM can only be mixed with
4166 * backbuffer formats WINED3DFMT_B5G5R5X1_UNORM and
4167 * WINED3DFMT_B5G5R5A1_UNORM. */
4168 if (display_format
== WINED3DFMT_B5G5R5X1_UNORM
4169 && !(backbuffer_format
== WINED3DFMT_B5G5R5X1_UNORM
|| backbuffer_format
== WINED3DFMT_B5G5R5A1_UNORM
))
4171 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4172 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4173 return WINED3DERR_NOTAVAILABLE
;
4176 /* In FULLSCREEN mode WINED3DFMT_B8G8R8X8_UNORM can only be mixed with
4177 * backbuffer formats WINED3DFMT_B8G8R8X8_UNORM and
4178 * WINED3DFMT_B8G8R8A8_UNORM. */
4179 if (display_format
== WINED3DFMT_B8G8R8X8_UNORM
4180 && !(backbuffer_format
== WINED3DFMT_B8G8R8X8_UNORM
|| backbuffer_format
== WINED3DFMT_B8G8R8A8_UNORM
))
4182 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4183 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4184 return WINED3DERR_NOTAVAILABLE
;
4187 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode and it
4188 * can only be mixed with backbuffer format WINED3DFMT_B10G10R10A2_UNORM. */
4189 if (display_format
== WINED3DFMT_B10G10R10A2_UNORM
4190 && (backbuffer_format
!= WINED3DFMT_B10G10R10A2_UNORM
|| windowed
))
4192 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4193 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4194 return WINED3DERR_NOTAVAILABLE
;
4197 /* Use CheckDeviceFormat to see if the backbuffer_format is usable with the given display_format */
4198 hr
= wined3d_check_device_format(wined3d
, adapter_idx
, device_type
, display_format
,
4199 WINED3DUSAGE_RENDERTARGET
, WINED3DRTYPE_SURFACE
, backbuffer_format
, SURFACE_OPENGL
);
4201 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4202 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4207 /* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
4208 subset of a D3DCAPS9 structure. However, it has to come via a void *
4209 as the d3d8 interface cannot import the d3d9 header */
4210 HRESULT CDECL
wined3d_get_device_caps(const struct wined3d
*wined3d
, UINT adapter_idx
,
4211 WINED3DDEVTYPE device_type
, WINED3DCAPS
*caps
)
4213 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
4214 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
4215 int vs_selected_mode
;
4216 int ps_selected_mode
;
4217 struct shader_caps shader_caps
;
4218 struct fragment_caps fragment_caps
;
4219 DWORD ckey_caps
, blit_caps
, fx_caps
, pal_caps
;
4221 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
4222 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), caps
);
4224 if (adapter_idx
>= wined3d
->adapter_count
)
4225 return WINED3DERR_INVALIDCALL
;
4227 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
4229 /* ------------------------------------------------
4230 The following fields apply to both d3d8 and d3d9
4231 ------------------------------------------------ */
4232 /* Not quite true, but use h/w supported by opengl I suppose */
4233 caps
->DeviceType
= (device_type
== WINED3DDEVTYPE_HAL
) ? WINED3DDEVTYPE_HAL
: WINED3DDEVTYPE_REF
;
4234 caps
->AdapterOrdinal
= adapter_idx
;
4237 caps
->Caps2
= WINED3DCAPS2_CANRENDERWINDOWED
|
4238 WINED3DCAPS2_FULLSCREENGAMMA
|
4239 WINED3DCAPS2_DYNAMICTEXTURES
;
4240 if (gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
4241 caps
->Caps2
|= WINED3DCAPS2_CANAUTOGENMIPMAP
;
4243 caps
->Caps3
= WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
4244 WINED3DCAPS3_COPY_TO_VIDMEM
|
4245 WINED3DCAPS3_COPY_TO_SYSTEMMEM
;
4247 caps
->PresentationIntervals
= WINED3DPRESENT_INTERVAL_IMMEDIATE
|
4248 WINED3DPRESENT_INTERVAL_ONE
;
4250 caps
->CursorCaps
= WINED3DCURSORCAPS_COLOR
|
4251 WINED3DCURSORCAPS_LOWRES
;
4253 caps
->DevCaps
= WINED3DDEVCAPS_FLOATTLVERTEX
|
4254 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY
|
4255 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
4256 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY
|
4257 WINED3DDEVCAPS_DRAWPRIMTLVERTEX
|
4258 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT
|
4259 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY
|
4260 WINED3DDEVCAPS_PUREDEVICE
|
4261 WINED3DDEVCAPS_HWRASTERIZATION
|
4262 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY
|
4263 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY
|
4264 WINED3DDEVCAPS_CANRENDERAFTERFLIP
|
4265 WINED3DDEVCAPS_DRAWPRIMITIVES2
|
4266 WINED3DDEVCAPS_DRAWPRIMITIVES2EX
|
4267 WINED3DDEVCAPS_RTPATCHES
;
4269 caps
->PrimitiveMiscCaps
= WINED3DPMISCCAPS_CULLNONE
|
4270 WINED3DPMISCCAPS_CULLCCW
|
4271 WINED3DPMISCCAPS_CULLCW
|
4272 WINED3DPMISCCAPS_COLORWRITEENABLE
|
4273 WINED3DPMISCCAPS_CLIPTLVERTS
|
4274 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
4275 WINED3DPMISCCAPS_MASKZ
|
4276 WINED3DPMISCCAPS_BLENDOP
|
4277 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
;
4279 WINED3DPMISCCAPS_NULLREFERENCE
4280 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
4281 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
4282 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
4284 if (gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
] && gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
4285 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_SEPARATEALPHABLEND
;
4286 if (gl_info
->supported
[EXT_DRAW_BUFFERS2
])
4287 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS
;
4289 caps
->RasterCaps
= WINED3DPRASTERCAPS_DITHER
|
4290 WINED3DPRASTERCAPS_PAT
|
4291 WINED3DPRASTERCAPS_WFOG
|
4292 WINED3DPRASTERCAPS_ZFOG
|
4293 WINED3DPRASTERCAPS_FOGVERTEX
|
4294 WINED3DPRASTERCAPS_FOGTABLE
|
4295 WINED3DPRASTERCAPS_STIPPLE
|
4296 WINED3DPRASTERCAPS_SUBPIXEL
|
4297 WINED3DPRASTERCAPS_ZTEST
|
4298 WINED3DPRASTERCAPS_SCISSORTEST
|
4299 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
4300 WINED3DPRASTERCAPS_DEPTHBIAS
;
4302 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4304 caps
->RasterCaps
|= WINED3DPRASTERCAPS_ANISOTROPY
|
4305 WINED3DPRASTERCAPS_ZBIAS
|
4306 WINED3DPRASTERCAPS_MIPMAPLODBIAS
;
4308 if (gl_info
->supported
[NV_FOG_DISTANCE
])
4310 caps
->RasterCaps
|= WINED3DPRASTERCAPS_FOGRANGE
;
4313 WINED3DPRASTERCAPS_COLORPERSPECTIVE
4314 WINED3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
4315 WINED3DPRASTERCAPS_ANTIALIASEDGES
4316 WINED3DPRASTERCAPS_ZBUFFERLESSHSR
4317 WINED3DPRASTERCAPS_WBUFFER */
4319 caps
->ZCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4320 WINED3DPCMPCAPS_EQUAL
|
4321 WINED3DPCMPCAPS_GREATER
|
4322 WINED3DPCMPCAPS_GREATEREQUAL
|
4323 WINED3DPCMPCAPS_LESS
|
4324 WINED3DPCMPCAPS_LESSEQUAL
|
4325 WINED3DPCMPCAPS_NEVER
|
4326 WINED3DPCMPCAPS_NOTEQUAL
;
4328 caps
->SrcBlendCaps
= WINED3DPBLENDCAPS_BOTHINVSRCALPHA
|
4329 WINED3DPBLENDCAPS_BOTHSRCALPHA
|
4330 WINED3DPBLENDCAPS_DESTALPHA
|
4331 WINED3DPBLENDCAPS_DESTCOLOR
|
4332 WINED3DPBLENDCAPS_INVDESTALPHA
|
4333 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4334 WINED3DPBLENDCAPS_INVSRCALPHA
|
4335 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4336 WINED3DPBLENDCAPS_ONE
|
4337 WINED3DPBLENDCAPS_SRCALPHA
|
4338 WINED3DPBLENDCAPS_SRCALPHASAT
|
4339 WINED3DPBLENDCAPS_SRCCOLOR
|
4340 WINED3DPBLENDCAPS_ZERO
;
4342 caps
->DestBlendCaps
= WINED3DPBLENDCAPS_DESTALPHA
|
4343 WINED3DPBLENDCAPS_DESTCOLOR
|
4344 WINED3DPBLENDCAPS_INVDESTALPHA
|
4345 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4346 WINED3DPBLENDCAPS_INVSRCALPHA
|
4347 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4348 WINED3DPBLENDCAPS_ONE
|
4349 WINED3DPBLENDCAPS_SRCALPHA
|
4350 WINED3DPBLENDCAPS_SRCCOLOR
|
4351 WINED3DPBLENDCAPS_ZERO
;
4352 /* NOTE: WINED3DPBLENDCAPS_SRCALPHASAT is not supported as dest blend factor,
4353 * according to the glBlendFunc manpage
4355 * WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA are
4356 * legacy settings for srcblend only
4359 if (gl_info
->supported
[EXT_BLEND_COLOR
])
4361 caps
->SrcBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4362 caps
->DestBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4366 caps
->AlphaCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4367 WINED3DPCMPCAPS_EQUAL
|
4368 WINED3DPCMPCAPS_GREATER
|
4369 WINED3DPCMPCAPS_GREATEREQUAL
|
4370 WINED3DPCMPCAPS_LESS
|
4371 WINED3DPCMPCAPS_LESSEQUAL
|
4372 WINED3DPCMPCAPS_NEVER
|
4373 WINED3DPCMPCAPS_NOTEQUAL
;
4375 caps
->ShadeCaps
= WINED3DPSHADECAPS_SPECULARGOURAUDRGB
|
4376 WINED3DPSHADECAPS_COLORGOURAUDRGB
|
4377 WINED3DPSHADECAPS_ALPHAFLATBLEND
|
4378 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND
|
4379 WINED3DPSHADECAPS_COLORFLATRGB
|
4380 WINED3DPSHADECAPS_FOGFLAT
|
4381 WINED3DPSHADECAPS_FOGGOURAUD
|
4382 WINED3DPSHADECAPS_SPECULARFLATRGB
;
4384 caps
->TextureCaps
= WINED3DPTEXTURECAPS_ALPHA
|
4385 WINED3DPTEXTURECAPS_ALPHAPALETTE
|
4386 WINED3DPTEXTURECAPS_TRANSPARENCY
|
4387 WINED3DPTEXTURECAPS_BORDER
|
4388 WINED3DPTEXTURECAPS_MIPMAP
|
4389 WINED3DPTEXTURECAPS_PROJECTED
|
4390 WINED3DPTEXTURECAPS_PERSPECTIVE
;
4392 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4394 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_POW2
|
4395 WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL
;
4398 if (gl_info
->supported
[EXT_TEXTURE3D
])
4400 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP
|
4401 WINED3DPTEXTURECAPS_MIPVOLUMEMAP
;
4402 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4404 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2
;
4408 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4410 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP
|
4411 WINED3DPTEXTURECAPS_MIPCUBEMAP
;
4412 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4414 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP_POW2
;
4418 caps
->TextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4419 WINED3DPTFILTERCAPS_MAGFPOINT
|
4420 WINED3DPTFILTERCAPS_MINFLINEAR
|
4421 WINED3DPTFILTERCAPS_MINFPOINT
|
4422 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4423 WINED3DPTFILTERCAPS_MIPFPOINT
|
4424 WINED3DPTFILTERCAPS_LINEAR
|
4425 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4426 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4427 WINED3DPTFILTERCAPS_MIPLINEAR
|
4428 WINED3DPTFILTERCAPS_MIPNEAREST
|
4429 WINED3DPTFILTERCAPS_NEAREST
;
4431 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4433 caps
->TextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4434 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4437 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4439 caps
->CubeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4440 WINED3DPTFILTERCAPS_MAGFPOINT
|
4441 WINED3DPTFILTERCAPS_MINFLINEAR
|
4442 WINED3DPTFILTERCAPS_MINFPOINT
|
4443 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4444 WINED3DPTFILTERCAPS_MIPFPOINT
|
4445 WINED3DPTFILTERCAPS_LINEAR
|
4446 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4447 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4448 WINED3DPTFILTERCAPS_MIPLINEAR
|
4449 WINED3DPTFILTERCAPS_MIPNEAREST
|
4450 WINED3DPTFILTERCAPS_NEAREST
;
4452 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4454 caps
->CubeTextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4455 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4460 caps
->CubeTextureFilterCaps
= 0;
4463 if (gl_info
->supported
[EXT_TEXTURE3D
])
4465 caps
->VolumeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4466 WINED3DPTFILTERCAPS_MAGFPOINT
|
4467 WINED3DPTFILTERCAPS_MINFLINEAR
|
4468 WINED3DPTFILTERCAPS_MINFPOINT
|
4469 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4470 WINED3DPTFILTERCAPS_MIPFPOINT
|
4471 WINED3DPTFILTERCAPS_LINEAR
|
4472 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4473 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4474 WINED3DPTFILTERCAPS_MIPLINEAR
|
4475 WINED3DPTFILTERCAPS_MIPNEAREST
|
4476 WINED3DPTFILTERCAPS_NEAREST
;
4480 caps
->VolumeTextureFilterCaps
= 0;
4483 caps
->TextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4484 WINED3DPTADDRESSCAPS_CLAMP
|
4485 WINED3DPTADDRESSCAPS_WRAP
;
4487 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4489 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4491 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4493 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4495 if (gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
4497 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4500 if (gl_info
->supported
[EXT_TEXTURE3D
])
4502 caps
->VolumeTextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4503 WINED3DPTADDRESSCAPS_CLAMP
|
4504 WINED3DPTADDRESSCAPS_WRAP
;
4505 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4507 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4509 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4511 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4513 if (gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
4515 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4520 caps
->VolumeTextureAddressCaps
= 0;
4523 caps
->LineCaps
= WINED3DLINECAPS_TEXTURE
|
4524 WINED3DLINECAPS_ZTEST
|
4525 WINED3DLINECAPS_BLEND
|
4526 WINED3DLINECAPS_ALPHACMP
|
4527 WINED3DLINECAPS_FOG
;
4528 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
4529 * idea how generating the smoothing alpha values works; the result is different
4532 caps
->MaxTextureWidth
= gl_info
->limits
.texture_size
;
4533 caps
->MaxTextureHeight
= gl_info
->limits
.texture_size
;
4535 if (gl_info
->supported
[EXT_TEXTURE3D
])
4536 caps
->MaxVolumeExtent
= gl_info
->limits
.texture3d_size
;
4538 caps
->MaxVolumeExtent
= 0;
4540 caps
->MaxTextureRepeat
= 32768;
4541 caps
->MaxTextureAspectRatio
= gl_info
->limits
.texture_size
;
4542 caps
->MaxVertexW
= 1.0f
;
4544 caps
->GuardBandLeft
= 0.0f
;
4545 caps
->GuardBandTop
= 0.0f
;
4546 caps
->GuardBandRight
= 0.0f
;
4547 caps
->GuardBandBottom
= 0.0f
;
4549 caps
->ExtentsAdjust
= 0.0f
;
4551 caps
->StencilCaps
= WINED3DSTENCILCAPS_DECRSAT
|
4552 WINED3DSTENCILCAPS_INCRSAT
|
4553 WINED3DSTENCILCAPS_INVERT
|
4554 WINED3DSTENCILCAPS_KEEP
|
4555 WINED3DSTENCILCAPS_REPLACE
|
4556 WINED3DSTENCILCAPS_ZERO
;
4557 if (gl_info
->supported
[EXT_STENCIL_WRAP
])
4559 caps
->StencilCaps
|= WINED3DSTENCILCAPS_DECR
|
4560 WINED3DSTENCILCAPS_INCR
;
4562 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
] || gl_info
->supported
[ATI_SEPARATE_STENCIL
])
4564 caps
->StencilCaps
|= WINED3DSTENCILCAPS_TWOSIDED
;
4567 caps
->FVFCaps
= WINED3DFVFCAPS_PSIZE
| 0x0008; /* 8 texture coords */
4569 caps
->MaxUserClipPlanes
= gl_info
->limits
.clipplanes
;
4570 caps
->MaxActiveLights
= gl_info
->limits
.lights
;
4572 caps
->MaxVertexBlendMatrices
= gl_info
->limits
.blends
;
4573 caps
->MaxVertexBlendMatrixIndex
= 0;
4575 caps
->MaxAnisotropy
= gl_info
->limits
.anisotropy
;
4576 caps
->MaxPointSize
= gl_info
->limits
.pointsize_max
;
4579 /* FIXME: Add D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */
4580 caps
->VertexProcessingCaps
= WINED3DVTXPCAPS_DIRECTIONALLIGHTS
|
4581 WINED3DVTXPCAPS_MATERIALSOURCE7
|
4582 WINED3DVTXPCAPS_POSITIONALLIGHTS
|
4583 WINED3DVTXPCAPS_LOCALVIEWER
|
4584 WINED3DVTXPCAPS_VERTEXFOG
|
4585 WINED3DVTXPCAPS_TEXGEN
;
4587 caps
->MaxPrimitiveCount
= 0xFFFFF; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
4588 caps
->MaxVertexIndex
= 0xFFFFF;
4589 caps
->MaxStreams
= MAX_STREAMS
;
4590 caps
->MaxStreamStride
= 1024;
4592 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
4593 caps
->DevCaps2
= WINED3DDEVCAPS2_STREAMOFFSET
|
4594 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
;
4595 caps
->MaxNpatchTessellationLevel
= 0;
4596 caps
->MasterAdapterOrdinal
= 0;
4597 caps
->AdapterOrdinalInGroup
= 0;
4598 caps
->NumberOfAdaptersInGroup
= 1;
4600 caps
->NumSimultaneousRTs
= gl_info
->limits
.buffers
;
4602 caps
->StretchRectFilterCaps
= WINED3DPTFILTERCAPS_MINFPOINT
|
4603 WINED3DPTFILTERCAPS_MAGFPOINT
|
4604 WINED3DPTFILTERCAPS_MINFLINEAR
|
4605 WINED3DPTFILTERCAPS_MAGFLINEAR
;
4606 caps
->VertexTextureFilterCaps
= 0;
4608 adapter
->shader_backend
->shader_get_caps(&adapter
->gl_info
, &shader_caps
);
4609 adapter
->fragment_pipe
->get_caps(&adapter
->gl_info
, &fragment_caps
);
4611 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
4612 caps
->PrimitiveMiscCaps
|= fragment_caps
.PrimitiveMiscCaps
;
4614 /* This takes care for disabling vertex shader or pixel shader caps while leaving the other one enabled.
4615 * Ignore shader model capabilities if disabled in config
4617 if (vs_selected_mode
== SHADER_NONE
)
4619 TRACE_(d3d_caps
)("Vertex shader disabled in config, reporting version 0.0\n");
4620 caps
->VertexShaderVersion
= WINED3DVS_VERSION(0,0);
4621 caps
->MaxVertexShaderConst
= 0;
4625 caps
->VertexShaderVersion
= shader_caps
.VertexShaderVersion
;
4626 caps
->MaxVertexShaderConst
= shader_caps
.MaxVertexShaderConst
;
4629 if (ps_selected_mode
== SHADER_NONE
)
4631 TRACE_(d3d_caps
)("Pixel shader disabled in config, reporting version 0.0\n");
4632 caps
->PixelShaderVersion
= WINED3DPS_VERSION(0,0);
4633 caps
->PixelShader1xMaxValue
= 0.0f
;
4635 caps
->PixelShaderVersion
= shader_caps
.PixelShaderVersion
;
4636 caps
->PixelShader1xMaxValue
= shader_caps
.PixelShader1xMaxValue
;
4639 caps
->TextureOpCaps
= fragment_caps
.TextureOpCaps
;
4640 caps
->MaxTextureBlendStages
= fragment_caps
.MaxTextureBlendStages
;
4641 caps
->MaxSimultaneousTextures
= fragment_caps
.MaxSimultaneousTextures
;
4643 /* The following caps are shader specific, but they are things we cannot detect, or which
4644 * are the same among all shader models. So to avoid code duplication set the shader version
4645 * specific, but otherwise constant caps here
4647 if (caps
->VertexShaderVersion
== WINED3DVS_VERSION(3,0))
4649 /* Where possible set the caps based on OpenGL extensions and if they
4650 * aren't set (in case of software rendering) use the VS 3.0 from
4651 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4653 caps
->VS20Caps
.Caps
= WINED3DVS20CAPS_PREDICATION
;
4654 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4655 caps
->VS20Caps
.DynamicFlowControlDepth
= WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4656 caps
->VS20Caps
.NumTemps
= max(32, adapter
->gl_info
.limits
.arb_vs_temps
);
4657 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
4658 caps
->VS20Caps
.StaticFlowControlDepth
= WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
4660 caps
->MaxVShaderInstructionsExecuted
= 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
4661 caps
->MaxVertexShader30InstructionSlots
= max(512, adapter
->gl_info
.limits
.arb_vs_instructions
);
4663 else if (caps
->VertexShaderVersion
== WINED3DVS_VERSION(2,0))
4665 caps
->VS20Caps
.Caps
= 0;
4666 caps
->VS20Caps
.DynamicFlowControlDepth
= WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
;
4667 caps
->VS20Caps
.NumTemps
= max(12, adapter
->gl_info
.limits
.arb_vs_temps
);
4668 caps
->VS20Caps
.StaticFlowControlDepth
= 1;
4670 caps
->MaxVShaderInstructionsExecuted
= 65535;
4671 caps
->MaxVertexShader30InstructionSlots
= 0;
4675 caps
->VS20Caps
.Caps
= 0;
4676 caps
->VS20Caps
.DynamicFlowControlDepth
= 0;
4677 caps
->VS20Caps
.NumTemps
= 0;
4678 caps
->VS20Caps
.StaticFlowControlDepth
= 0;
4680 caps
->MaxVShaderInstructionsExecuted
= 0;
4681 caps
->MaxVertexShader30InstructionSlots
= 0;
4684 if (caps
->PixelShaderVersion
== WINED3DPS_VERSION(3,0))
4686 /* Where possible set the caps based on OpenGL extensions and if they
4687 * aren't set (in case of software rendering) use the PS 3.0 from
4688 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4691 /* Caps is more or less undocumented on MSDN but it appears to be
4692 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
4693 * cards from Windows */
4694 caps
->PS20Caps
.Caps
= WINED3DPS20CAPS_ARBITRARYSWIZZLE
|
4695 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS
|
4696 WINED3DPS20CAPS_PREDICATION
|
4697 WINED3DPS20CAPS_NODEPENDENTREADLIMIT
|
4698 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
4699 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4700 caps
->PS20Caps
.DynamicFlowControlDepth
= WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4701 caps
->PS20Caps
.NumTemps
= max(32, adapter
->gl_info
.limits
.arb_ps_temps
);
4702 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
4703 caps
->PS20Caps
.StaticFlowControlDepth
= WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
4704 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
4705 caps
->PS20Caps
.NumInstructionSlots
= WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
4707 caps
->MaxPShaderInstructionsExecuted
= 65535;
4708 caps
->MaxPixelShader30InstructionSlots
= max(WINED3DMIN30SHADERINSTRUCTIONS
,
4709 adapter
->gl_info
.limits
.arb_ps_instructions
);
4711 else if(caps
->PixelShaderVersion
== WINED3DPS_VERSION(2,0))
4713 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
4714 caps
->PS20Caps
.Caps
= 0;
4715 caps
->PS20Caps
.DynamicFlowControlDepth
= 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
4716 caps
->PS20Caps
.NumTemps
= max(12, adapter
->gl_info
.limits
.arb_ps_temps
);
4717 caps
->PS20Caps
.StaticFlowControlDepth
= WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH
; /* Minimum: 1 */
4718 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
4719 caps
->PS20Caps
.NumInstructionSlots
= WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS
;
4721 caps
->MaxPShaderInstructionsExecuted
= 512; /* Minimum value, a GeforceFX uses 1024 */
4722 caps
->MaxPixelShader30InstructionSlots
= 0;
4726 caps
->PS20Caps
.Caps
= 0;
4727 caps
->PS20Caps
.DynamicFlowControlDepth
= 0;
4728 caps
->PS20Caps
.NumTemps
= 0;
4729 caps
->PS20Caps
.StaticFlowControlDepth
= 0;
4730 caps
->PS20Caps
.NumInstructionSlots
= 0;
4732 caps
->MaxPShaderInstructionsExecuted
= 0;
4733 caps
->MaxPixelShader30InstructionSlots
= 0;
4736 if (caps
->VertexShaderVersion
>= WINED3DVS_VERSION(2,0))
4738 /* OpenGL supports all the formats below, perhaps not always
4739 * without conversion, but it supports them.
4740 * Further GLSL doesn't seem to have an official unsigned type so
4741 * don't advertise it yet as I'm not sure how we handle it.
4742 * We might need to add some clamping in the shader engine to
4744 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
4745 caps
->DeclTypes
= WINED3DDTCAPS_UBYTE4
|
4746 WINED3DDTCAPS_UBYTE4N
|
4747 WINED3DDTCAPS_SHORT2N
|
4748 WINED3DDTCAPS_SHORT4N
;
4749 if (gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
])
4751 caps
->DeclTypes
|= WINED3DDTCAPS_FLOAT16_2
|
4752 WINED3DDTCAPS_FLOAT16_4
;
4757 caps
->DeclTypes
= 0;
4760 /* Set DirectDraw helper Caps */
4761 ckey_caps
= WINEDDCKEYCAPS_DESTBLT
|
4762 WINEDDCKEYCAPS_SRCBLT
;
4763 fx_caps
= WINEDDFXCAPS_BLTALPHA
|
4764 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT
|
4765 WINEDDFXCAPS_BLTMIRRORUPDOWN
|
4766 WINEDDFXCAPS_BLTROTATION90
|
4767 WINEDDFXCAPS_BLTSHRINKX
|
4768 WINEDDFXCAPS_BLTSHRINKXN
|
4769 WINEDDFXCAPS_BLTSHRINKY
|
4770 WINEDDFXCAPS_BLTSHRINKXN
|
4771 WINEDDFXCAPS_BLTSTRETCHX
|
4772 WINEDDFXCAPS_BLTSTRETCHXN
|
4773 WINEDDFXCAPS_BLTSTRETCHY
|
4774 WINEDDFXCAPS_BLTSTRETCHYN
;
4775 blit_caps
= WINEDDCAPS_BLT
|
4776 WINEDDCAPS_BLTCOLORFILL
|
4777 WINEDDCAPS_BLTDEPTHFILL
|
4778 WINEDDCAPS_BLTSTRETCH
|
4779 WINEDDCAPS_CANBLTSYSMEM
|
4780 WINEDDCAPS_CANCLIP
|
4781 WINEDDCAPS_CANCLIPSTRETCHED
|
4782 WINEDDCAPS_COLORKEY
|
4783 WINEDDCAPS_COLORKEYHWASSIST
|
4784 WINEDDCAPS_ALIGNBOUNDARYSRC
;
4785 pal_caps
= WINEDDPCAPS_8BIT
|
4786 WINEDDPCAPS_PRIMARYSURFACE
;
4788 /* Fill the ddraw caps structure */
4789 caps
->DirectDrawCaps
.Caps
= WINEDDCAPS_GDI
|
4790 WINEDDCAPS_PALETTE
|
4792 caps
->DirectDrawCaps
.Caps2
= WINEDDCAPS2_CERTIFIED
|
4793 WINEDDCAPS2_NOPAGELOCKREQUIRED
|
4794 WINEDDCAPS2_PRIMARYGAMMA
|
4795 WINEDDCAPS2_WIDESURFACES
|
4796 WINEDDCAPS2_CANRENDERWINDOWED
;
4797 caps
->DirectDrawCaps
.CKeyCaps
= ckey_caps
;
4798 caps
->DirectDrawCaps
.FXCaps
= fx_caps
;
4799 caps
->DirectDrawCaps
.PalCaps
= pal_caps
;
4800 caps
->DirectDrawCaps
.SVBCaps
= blit_caps
;
4801 caps
->DirectDrawCaps
.SVBCKeyCaps
= ckey_caps
;
4802 caps
->DirectDrawCaps
.SVBFXCaps
= fx_caps
;
4803 caps
->DirectDrawCaps
.VSBCaps
= blit_caps
;
4804 caps
->DirectDrawCaps
.VSBCKeyCaps
= ckey_caps
;
4805 caps
->DirectDrawCaps
.VSBFXCaps
= fx_caps
;
4806 caps
->DirectDrawCaps
.SSBCaps
= blit_caps
;
4807 caps
->DirectDrawCaps
.SSBCKeyCaps
= ckey_caps
;
4808 caps
->DirectDrawCaps
.SSBFXCaps
= fx_caps
;
4810 caps
->DirectDrawCaps
.ddsCaps
= WINEDDSCAPS_ALPHA
|
4811 WINEDDSCAPS_BACKBUFFER
|
4813 WINEDDSCAPS_FRONTBUFFER
|
4814 WINEDDSCAPS_OFFSCREENPLAIN
|
4815 WINEDDSCAPS_PALETTE
|
4816 WINEDDSCAPS_PRIMARYSURFACE
|
4817 WINEDDSCAPS_SYSTEMMEMORY
|
4818 WINEDDSCAPS_VIDEOMEMORY
|
4819 WINEDDSCAPS_VISIBLE
;
4820 caps
->DirectDrawCaps
.StrideAlign
= DDRAW_PITCH_ALIGNMENT
;
4822 /* Set D3D caps if OpenGL is available. */
4823 if (adapter
->opengl
)
4825 caps
->DirectDrawCaps
.ddsCaps
|= WINEDDSCAPS_3DDEVICE
|
4826 WINEDDSCAPS_MIPMAP
|
4827 WINEDDSCAPS_TEXTURE
|
4828 WINEDDSCAPS_ZBUFFER
;
4829 caps
->DirectDrawCaps
.Caps
|= WINEDDCAPS_3D
;
4835 HRESULT CDECL
wined3d_device_create(struct wined3d
*wined3d
, UINT adapter_idx
, WINED3DDEVTYPE device_type
,
4836 HWND focus_window
, DWORD flags
, IWineD3DDeviceParent
*device_parent
, IWineD3DDevice
**device
)
4838 IWineD3DDeviceImpl
*object
;
4841 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, device_parent %p, device %p.\n",
4842 wined3d
, adapter_idx
, device_type
, focus_window
, flags
, device_parent
, device
);
4844 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
4845 * number and create a device without a 3D adapter for 2D only operation. */
4846 if (wined3d
->adapter_count
&& adapter_idx
>= wined3d
->adapter_count
)
4847 return WINED3DERR_INVALIDCALL
;
4849 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
4852 ERR("Failed to allocate device memory.\n");
4853 return E_OUTOFMEMORY
;
4856 hr
= device_init(object
, wined3d
, adapter_idx
, device_type
, focus_window
, flags
, device_parent
);
4859 WARN("Failed to initialize device, hr %#x.\n", hr
);
4860 HeapFree(GetProcessHeap(), 0, object
);
4864 TRACE("Created device %p.\n", object
);
4865 *device
= (IWineD3DDevice
*)object
;
4867 IWineD3DDeviceParent_WineD3DDeviceCreated(device_parent
, *device
);
4872 void * CDECL
wined3d_get_parent(const struct wined3d
*wined3d
)
4874 TRACE("wined3d %p.\n", wined3d
);
4876 return wined3d
->parent
;
4879 static void WINE_GLAPI
invalid_func(const void *data
)
4881 ERR("Invalid vertex attribute function called\n");
4885 static void WINE_GLAPI
invalid_texcoord_func(GLenum unit
, const void *data
)
4887 ERR("Invalid texcoord function called\n");
4891 /* Helper functions for providing vertex data to opengl. The arrays are initialized based on
4892 * the extension detection and are used in drawStridedSlow
4894 static void WINE_GLAPI
position_d3dcolor(const void *data
)
4896 DWORD pos
= *((const DWORD
*)data
);
4898 FIXME("Add a test for fixed function position from d3dcolor type\n");
4899 glVertex4s(D3DCOLOR_B_R(pos
),
4905 static void WINE_GLAPI
position_float4(const void *data
)
4907 const GLfloat
*pos
= data
;
4909 if (pos
[3] != 0.0f
&& pos
[3] != 1.0f
)
4911 float w
= 1.0f
/ pos
[3];
4913 glVertex4f(pos
[0] * w
, pos
[1] * w
, pos
[2] * w
, w
);
4921 static void WINE_GLAPI
diffuse_d3dcolor(const void *data
)
4923 DWORD diffuseColor
= *((const DWORD
*)data
);
4925 glColor4ub(D3DCOLOR_B_R(diffuseColor
),
4926 D3DCOLOR_B_G(diffuseColor
),
4927 D3DCOLOR_B_B(diffuseColor
),
4928 D3DCOLOR_B_A(diffuseColor
));
4931 static void WINE_GLAPI
specular_d3dcolor(const void *data
)
4933 DWORD specularColor
= *((const DWORD
*)data
);
4934 GLbyte d
[] = {D3DCOLOR_B_R(specularColor
),
4935 D3DCOLOR_B_G(specularColor
),
4936 D3DCOLOR_B_B(specularColor
)};
4938 specular_func_3ubv(d
);
4941 static void WINE_GLAPI
warn_no_specular_func(const void *data
)
4943 WARN("GL_EXT_secondary_color not supported\n");
4946 static void fillGLAttribFuncs(const struct wined3d_gl_info
*gl_info
)
4948 position_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
4949 position_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
4950 position_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glVertex3fv
;
4951 position_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = position_float4
;
4952 position_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = position_d3dcolor
;
4953 position_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
4954 position_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
4955 position_funcs
[WINED3D_FFP_EMIT_SHORT4
] = (glAttribFunc
)glVertex2sv
;
4956 position_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
4957 position_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
4958 position_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
4959 position_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
4960 position_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
4961 position_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
4962 position_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
4963 position_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
4964 position_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
4966 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
4967 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
4968 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glColor3fv
;
4969 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glAttribFunc
)glColor4fv
;
4970 diffuse_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = diffuse_d3dcolor
;
4971 diffuse_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
4972 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
4973 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
4974 diffuse_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = (glAttribFunc
)glColor4ubv
;
4975 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
4976 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = (glAttribFunc
)glColor4sv
;
4977 diffuse_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
4978 diffuse_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = (glAttribFunc
)glColor4usv
;
4979 diffuse_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
4980 diffuse_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
4981 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
4982 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
4984 /* No 4 component entry points here */
4985 specular_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
4986 specular_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
4987 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4989 specular_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)GL_EXTCALL(glSecondaryColor3fvEXT
);
4993 specular_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = warn_no_specular_func
;
4995 specular_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = invalid_func
;
4996 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4998 specular_func_3ubv
= (glAttribFunc
)GL_EXTCALL(glSecondaryColor3ubvEXT
);
4999 specular_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = specular_d3dcolor
;
5003 specular_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = warn_no_specular_func
;
5005 specular_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5006 specular_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5007 specular_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5008 specular_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5009 specular_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5010 specular_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5011 specular_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5012 specular_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5013 specular_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5014 specular_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5015 specular_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5016 specular_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5018 /* Only 3 component entry points here. Test how others behave. Float4 normals are used
5019 * by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
5021 normal_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5022 normal_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5023 normal_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glNormal3fv
;
5024 normal_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glAttribFunc
)glNormal3fv
; /* Just ignore the 4th value */
5025 normal_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_func
;
5026 normal_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5027 normal_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5028 normal_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5029 normal_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5030 normal_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5031 normal_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5032 normal_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5033 normal_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5034 normal_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5035 normal_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5036 normal_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5037 normal_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5039 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord1fvARB
);
5040 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2fvARB
);
5041 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord3fvARB
);
5042 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4fvARB
);
5043 multi_texcoord_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_texcoord_func
;
5044 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_texcoord_func
;
5045 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2svARB
);
5046 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4svARB
);
5047 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_texcoord_func
;
5048 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_texcoord_func
;
5049 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_texcoord_func
;
5050 multi_texcoord_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_texcoord_func
;
5051 multi_texcoord_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_texcoord_func
;
5052 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_texcoord_func
;
5053 multi_texcoord_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_texcoord_func
;
5054 if (gl_info
->supported
[NV_HALF_FLOAT
])
5056 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT */
5057 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2hvNV
);
5058 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4hvNV
);
5060 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_texcoord_func
;
5061 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_texcoord_func
;
5065 /* Do not call while under the GL lock. */
5066 static BOOL
InitAdapters(struct wined3d
*wined3d
)
5068 static HMODULE mod_gl
;
5070 int ps_selected_mode
, vs_selected_mode
;
5072 /* No need to hold any lock. The calling library makes sure only one thread calls
5073 * wined3d simultaneously
5076 TRACE("Initializing adapters\n");
5079 #ifdef USE_WIN32_OPENGL
5080 #define USE_GL_FUNC(pfn) pfn = (void*)GetProcAddress(mod_gl, #pfn);
5081 mod_gl
= LoadLibraryA("opengl32.dll");
5083 ERR("Can't load opengl32.dll!\n");
5087 #define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);
5088 /* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 (glXGetProcAddress wrapper) instead of opengl32's */
5089 mod_gl
= GetModuleHandleA("gdi32.dll");
5093 /* Load WGL core functions from opengl32.dll */
5094 #define USE_WGL_FUNC(pfn) p##pfn = (void*)GetProcAddress(mod_gl, #pfn);
5098 if(!pwglGetProcAddress
) {
5099 ERR("Unable to load wglGetProcAddress!\n");
5103 /* Dynamically load all GL core functions */
5107 /* Load glFinish and glFlush from opengl32.dll even if we're not using WIN32 opengl
5108 * otherwise because we have to use winex11.drv's override
5110 #ifdef USE_WIN32_OPENGL
5111 wglFinish
= (void*)GetProcAddress(mod_gl
, "glFinish");
5112 wglFlush
= (void*)GetProcAddress(mod_gl
, "glFlush");
5114 wglFinish
= (void*)pwglGetProcAddress("wglFinish");
5115 wglFlush
= (void*)pwglGetProcAddress("wglFlush");
5118 glEnableWINE
= glEnable
;
5119 glDisableWINE
= glDisable
;
5121 /* For now only one default adapter */
5123 struct wined3d_adapter
*adapter
= &wined3d
->adapters
[0];
5124 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
5125 struct wined3d_fake_gl_ctx fake_gl_ctx
= {0};
5129 WineD3D_PixelFormat
*cfgs
;
5130 DISPLAY_DEVICEW DisplayDevice
;
5133 TRACE("Initializing default adapter\n");
5134 adapter
->ordinal
= 0;
5135 adapter
->monitorPoint
.x
= -1;
5136 adapter
->monitorPoint
.y
= -1;
5138 if (!AllocateLocallyUniqueId(&adapter
->luid
))
5140 DWORD err
= GetLastError();
5141 ERR("Failed to set adapter LUID (%#x).\n", err
);
5144 TRACE("Allocated LUID %08x:%08x for adapter.\n",
5145 adapter
->luid
.HighPart
, adapter
->luid
.LowPart
);
5147 if (!WineD3D_CreateFakeGLContext(&fake_gl_ctx
))
5149 ERR("Failed to get a gl context for default adapter\n");
5153 ret
= IWineD3DImpl_FillGLCaps(adapter
);
5155 ERR("Failed to initialize gl caps for default adapter\n");
5156 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5159 ret
= initPixelFormats(&adapter
->gl_info
, adapter
->driver_info
.vendor
);
5161 ERR("Failed to init gl formats\n");
5162 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5166 hdc
= fake_gl_ctx
.dc
;
5168 adapter
->TextureRam
= adapter
->driver_info
.vidmem
;
5169 adapter
->UsedTextureRam
= 0;
5170 TRACE("Emulating %dMB of texture ram\n", adapter
->TextureRam
/(1024*1024));
5172 /* Initialize the Adapter's DeviceName which is required for ChangeDisplaySettings and friends */
5173 DisplayDevice
.cb
= sizeof(DisplayDevice
);
5174 EnumDisplayDevicesW(NULL
, 0 /* Adapter 0 = iDevNum 0 */, &DisplayDevice
, 0);
5175 TRACE("DeviceName: %s\n", debugstr_w(DisplayDevice
.DeviceName
));
5176 strcpyW(adapter
->DeviceName
, DisplayDevice
.DeviceName
);
5178 if (gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
])
5185 attribute
= WGL_NUMBER_PIXEL_FORMATS_ARB
;
5186 GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, 0, 0, 1, &attribute
, &adapter
->nCfgs
));
5188 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, adapter
->nCfgs
*sizeof(WineD3D_PixelFormat
));
5189 cfgs
= adapter
->cfgs
;
5190 attribs
[nAttribs
++] = WGL_RED_BITS_ARB
;
5191 attribs
[nAttribs
++] = WGL_GREEN_BITS_ARB
;
5192 attribs
[nAttribs
++] = WGL_BLUE_BITS_ARB
;
5193 attribs
[nAttribs
++] = WGL_ALPHA_BITS_ARB
;
5194 attribs
[nAttribs
++] = WGL_COLOR_BITS_ARB
;
5195 attribs
[nAttribs
++] = WGL_DEPTH_BITS_ARB
;
5196 attribs
[nAttribs
++] = WGL_STENCIL_BITS_ARB
;
5197 attribs
[nAttribs
++] = WGL_DRAW_TO_WINDOW_ARB
;
5198 attribs
[nAttribs
++] = WGL_PIXEL_TYPE_ARB
;
5199 attribs
[nAttribs
++] = WGL_DOUBLE_BUFFER_ARB
;
5200 attribs
[nAttribs
++] = WGL_AUX_BUFFERS_ARB
;
5202 for (iPixelFormat
=1; iPixelFormat
<= adapter
->nCfgs
; ++iPixelFormat
)
5204 res
= GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0, nAttribs
, attribs
, values
));
5209 /* Cache the pixel format */
5210 cfgs
->iPixelFormat
= iPixelFormat
;
5211 cfgs
->redSize
= values
[0];
5212 cfgs
->greenSize
= values
[1];
5213 cfgs
->blueSize
= values
[2];
5214 cfgs
->alphaSize
= values
[3];
5215 cfgs
->colorSize
= values
[4];
5216 cfgs
->depthSize
= values
[5];
5217 cfgs
->stencilSize
= values
[6];
5218 cfgs
->windowDrawable
= values
[7];
5219 cfgs
->iPixelType
= values
[8];
5220 cfgs
->doubleBuffer
= values
[9];
5221 cfgs
->auxBuffers
= values
[10];
5223 cfgs
->numSamples
= 0;
5224 /* Check multisample support */
5225 if (gl_info
->supported
[ARB_MULTISAMPLE
])
5227 int attrib
[2] = {WGL_SAMPLE_BUFFERS_ARB
, WGL_SAMPLES_ARB
};
5229 if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0, 2, attrib
, value
))) {
5230 /* value[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether multisampling is supported.
5231 * value[1] = number of multi sample buffers*/
5233 cfgs
->numSamples
= value
[1];
5237 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5238 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
5239 cfgs
->iPixelFormat
, cfgs
->iPixelType
, cfgs
->doubleBuffer
,
5240 cfgs
->redSize
, cfgs
->greenSize
, cfgs
->blueSize
, cfgs
->alphaSize
,
5241 cfgs
->depthSize
, cfgs
->stencilSize
, cfgs
->numSamples
, cfgs
->windowDrawable
);
5247 int nCfgs
= DescribePixelFormat(hdc
, 0, 0, 0);
5248 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, nCfgs
*sizeof(WineD3D_PixelFormat
));
5249 adapter
->nCfgs
= 0; /* We won't accept all formats e.g. software accelerated ones will be skipped */
5251 cfgs
= adapter
->cfgs
;
5252 for(iPixelFormat
=1; iPixelFormat
<=nCfgs
; iPixelFormat
++)
5254 PIXELFORMATDESCRIPTOR ppfd
;
5256 res
= DescribePixelFormat(hdc
, iPixelFormat
, sizeof(PIXELFORMATDESCRIPTOR
), &ppfd
);
5260 /* We only want HW acceleration using an OpenGL ICD driver.
5261 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering
5262 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD driver (e.g. 3dfx minigl)
5264 if(ppfd
.dwFlags
& (PFD_GENERIC_FORMAT
| PFD_GENERIC_ACCELERATED
))
5266 TRACE("Skipping iPixelFormat=%d because it isn't ICD accelerated\n", iPixelFormat
);
5270 cfgs
->iPixelFormat
= iPixelFormat
;
5271 cfgs
->redSize
= ppfd
.cRedBits
;
5272 cfgs
->greenSize
= ppfd
.cGreenBits
;
5273 cfgs
->blueSize
= ppfd
.cBlueBits
;
5274 cfgs
->alphaSize
= ppfd
.cAlphaBits
;
5275 cfgs
->colorSize
= ppfd
.cColorBits
;
5276 cfgs
->depthSize
= ppfd
.cDepthBits
;
5277 cfgs
->stencilSize
= ppfd
.cStencilBits
;
5278 cfgs
->windowDrawable
= (ppfd
.dwFlags
& PFD_DRAW_TO_WINDOW
) ? 1 : 0;
5279 cfgs
->iPixelType
= (ppfd
.iPixelType
== PFD_TYPE_RGBA
) ? WGL_TYPE_RGBA_ARB
: WGL_TYPE_COLORINDEX_ARB
;
5280 cfgs
->doubleBuffer
= (ppfd
.dwFlags
& PFD_DOUBLEBUFFER
) ? 1 : 0;
5281 cfgs
->auxBuffers
= ppfd
.cAuxBuffers
;
5282 cfgs
->numSamples
= 0;
5284 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5285 "depth=%d, stencil=%d, windowDrawable=%d\n",
5286 cfgs
->iPixelFormat
, cfgs
->iPixelType
, cfgs
->doubleBuffer
,
5287 cfgs
->redSize
, cfgs
->greenSize
, cfgs
->blueSize
, cfgs
->alphaSize
,
5288 cfgs
->depthSize
, cfgs
->stencilSize
, cfgs
->windowDrawable
);
5293 /* Yikes we haven't found any suitable formats. This should only happen in case of GDI software rendering which we can't use anyway as its 3D functionality is very, very limited */
5296 ERR("Disabling Direct3D because no hardware accelerated pixel formats have been found!\n");
5298 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5299 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
5304 /* D16, D24X8 and D24S8 are common depth / depth+stencil formats. All drivers support them though this doesn't
5305 * mean that the format is offered in hardware. For instance Geforce8 cards don't have offer D16 in hardware
5306 * but just fake it using D24(X8?) which is fine. D3D also allows that.
5307 * Some display drivers (i915 on Linux) only report mixed depth+stencil formats like D24S8. MSDN clearly mentions
5308 * that only on lockable formats (e.g. D16_locked) the bit order is guaranteed and that on other formats the
5309 * driver is allowed to consume more bits EXCEPT for stencil bits.
5311 * Mark an adapter with this broken stencil behavior.
5313 adapter
->brokenStencil
= TRUE
;
5314 for (i
= 0, cfgs
= adapter
->cfgs
; i
< adapter
->nCfgs
; ++i
)
5316 /* Nearly all drivers offer depth formats without stencil, only on i915 this if-statement won't be entered. */
5317 if(cfgs
[i
].depthSize
&& !cfgs
[i
].stencilSize
) {
5318 adapter
->brokenStencil
= FALSE
;
5323 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5325 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
5326 fillGLAttribFuncs(&adapter
->gl_info
);
5327 adapter
->opengl
= TRUE
;
5329 wined3d
->adapter_count
= 1;
5330 TRACE("%u adapters successfully initialized.\n", wined3d
->adapter_count
);
5335 /* Initialize an adapter for ddraw-only memory counting */
5336 memset(wined3d
->adapters
, 0, sizeof(wined3d
->adapters
));
5337 wined3d
->adapters
[0].ordinal
= 0;
5338 wined3d
->adapters
[0].opengl
= FALSE
;
5339 wined3d
->adapters
[0].monitorPoint
.x
= -1;
5340 wined3d
->adapters
[0].monitorPoint
.y
= -1;
5342 wined3d
->adapters
[0].driver_info
.name
= "Display";
5343 wined3d
->adapters
[0].driver_info
.description
= "WineD3D DirectDraw Emulation";
5344 if (wined3d_settings
.emulated_textureram
)
5345 wined3d
->adapters
[0].TextureRam
= wined3d_settings
.emulated_textureram
;
5347 wined3d
->adapters
[0].TextureRam
= 8 * 1024 * 1024; /* This is plenty for a DDraw-only card */
5349 initPixelFormatsNoGL(&wined3d
->adapters
[0].gl_info
);
5351 wined3d
->adapter_count
= 1;
5355 static void STDMETHODCALLTYPE
wined3d_null_wined3d_object_destroyed(void *parent
) {}
5357 const struct wined3d_parent_ops wined3d_null_parent_ops
=
5359 wined3d_null_wined3d_object_destroyed
,
5362 /* Do not call while under the GL lock. */
5363 HRESULT
wined3d_init(struct wined3d
*wined3d
, UINT version
, void *parent
)
5365 wined3d
->dxVersion
= version
;
5367 wined3d
->parent
= parent
;
5369 if (!InitAdapters(wined3d
))
5371 WARN("Failed to initialize adapters.\n");
5374 MESSAGE("Direct3D%u is not available without OpenGL.\n", version
);