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_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX
, 0 },
59 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM
, 0 },
60 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER
, 0 },
61 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT
, 0 },
62 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4
, 0 },
63 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL
, 0 },
64 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX
, 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_blend_subtract", EXT_BLEND_SUBTRACT
, 0 },
109 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST
, 0 },
110 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2
, 0 },
111 {"GL_EXT_fog_coord", EXT_FOG_COORD
, 0 },
112 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT
, 0 },
113 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE
, 0 },
114 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT
, 0 },
115 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS
, 0 },
116 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4
, 0 },
117 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL
, 0 },
118 {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE
, 0 },
119 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS
, 0 },
120 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX
, 0 },
121 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR
, 0 },
122 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE
, 0 },
123 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP
, 0 },
124 {"GL_EXT_texture3D", EXT_TEXTURE3D
, MAKEDWORD_VERSION(1, 2) },
125 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC
, 0 },
126 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC
, 0 },
127 {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD
, 0 },
128 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE
, 0 },
129 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3
, 0 },
130 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC
, 0 },
131 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS
, 0 },
132 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB
, 0 },
133 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE
, 0 },
134 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA
, 0 },
137 {"GL_NV_depth_clamp", NV_DEPTH_CLAMP
, 0 },
138 {"GL_NV_fence", NV_FENCE
, 0 },
139 {"GL_NV_fog_distance", NV_FOG_DISTANCE
, 0 },
140 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM
, 0 },
141 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2
, 0 },
142 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION
, 0 },
143 {"GL_NV_half_float", NV_HALF_FLOAT
, 0 },
144 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT
, 0 },
145 {"GL_NV_point_sprite", NV_POINT_SPRITE
, 0 },
146 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS
, 0 },
147 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2
, 0 },
148 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION
, 0 },
149 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4
, 0 },
150 {"GL_NV_texture_shader", NV_TEXTURE_SHADER
, 0 },
151 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2
, 0 },
152 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM
, 0 },
153 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1
, 0 },
154 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2
, 0 },
155 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION
, 0 },
156 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3
, 0 },
159 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP
, 0 },
162 /**********************************************************
163 * Utility functions follow
164 **********************************************************/
166 const struct min_lookup minMipLookup
[] =
168 /* NONE POINT LINEAR */
169 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
170 {{GL_NEAREST
, GL_NEAREST_MIPMAP_NEAREST
, GL_NEAREST_MIPMAP_LINEAR
}}, /* POINT*/
171 {{GL_LINEAR
, GL_LINEAR_MIPMAP_NEAREST
, GL_LINEAR_MIPMAP_LINEAR
}}, /* LINEAR */
174 const struct min_lookup minMipLookup_noFilter
[] =
176 /* NONE POINT LINEAR */
177 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
178 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
179 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* LINEAR */
182 const struct min_lookup minMipLookup_noMip
[] =
184 /* NONE POINT LINEAR */
185 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
186 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
187 {{GL_LINEAR
, GL_LINEAR
, GL_LINEAR
}}, /* LINEAR */
190 const GLenum magLookup
[] =
192 /* NONE POINT LINEAR */
193 GL_NEAREST
, GL_NEAREST
, GL_LINEAR
,
196 const GLenum magLookup_noFilter
[] =
198 /* NONE POINT LINEAR */
199 GL_NEAREST
, GL_NEAREST
, GL_NEAREST
,
202 /* drawStridedSlow attributes */
203 glAttribFunc position_funcs
[WINED3D_FFP_EMIT_COUNT
];
204 glAttribFunc diffuse_funcs
[WINED3D_FFP_EMIT_COUNT
];
205 glAttribFunc specular_func_3ubv
;
206 glAttribFunc specular_funcs
[WINED3D_FFP_EMIT_COUNT
];
207 glAttribFunc normal_funcs
[WINED3D_FFP_EMIT_COUNT
];
208 glMultiTexCoordFunc multi_texcoord_funcs
[WINED3D_FFP_EMIT_COUNT
];
211 * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
212 * i.e., there is no GL Context - Get a default rendering context to enable the
213 * function query some info from GL.
216 struct wined3d_fake_gl_ctx
222 HGLRC restore_gl_ctx
;
225 static void WineD3D_ReleaseFakeGLContext(struct wined3d_fake_gl_ctx
*ctx
)
227 TRACE_(d3d_caps
)("Destroying fake GL context.\n");
229 if (!pwglMakeCurrent(NULL
, NULL
))
231 ERR_(d3d_caps
)("Failed to disable fake GL context.\n");
234 if (!pwglDeleteContext(ctx
->gl_ctx
))
236 DWORD err
= GetLastError();
237 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx
->gl_ctx
, err
);
240 ReleaseDC(ctx
->wnd
, ctx
->dc
);
241 DestroyWindow(ctx
->wnd
);
243 if (ctx
->restore_gl_ctx
&& !pwglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
245 ERR_(d3d_caps
)("Failed to restore previous GL context.\n");
249 /* Do not call while under the GL lock. */
250 static BOOL
WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx
*ctx
)
252 PIXELFORMATDESCRIPTOR pfd
;
255 TRACE("getting context...\n");
257 ctx
->restore_dc
= pwglGetCurrentDC();
258 ctx
->restore_gl_ctx
= pwglGetCurrentContext();
260 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
261 ctx
->wnd
= CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME
, "WineD3D fake window",
262 WS_OVERLAPPEDWINDOW
, 10, 10, 10, 10, NULL
, NULL
, NULL
, NULL
);
265 ERR_(d3d_caps
)("Failed to create a window.\n");
269 ctx
->dc
= GetDC(ctx
->wnd
);
272 ERR_(d3d_caps
)("Failed to get a DC.\n");
276 /* PixelFormat selection */
277 ZeroMemory(&pfd
, sizeof(pfd
));
278 pfd
.nSize
= sizeof(pfd
);
280 pfd
.dwFlags
= PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER
| PFD_DRAW_TO_WINDOW
; /* PFD_GENERIC_ACCELERATED */
281 pfd
.iPixelType
= PFD_TYPE_RGBA
;
283 pfd
.iLayerType
= PFD_MAIN_PLANE
;
285 iPixelFormat
= ChoosePixelFormat(ctx
->dc
, &pfd
);
288 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
289 ERR_(d3d_caps
)("Can't find a suitable iPixelFormat.\n");
292 DescribePixelFormat(ctx
->dc
, iPixelFormat
, sizeof(pfd
), &pfd
);
293 SetPixelFormat(ctx
->dc
, iPixelFormat
, &pfd
);
295 /* Create a GL context. */
296 ctx
->gl_ctx
= pwglCreateContext(ctx
->dc
);
299 WARN_(d3d_caps
)("Error creating default context for capabilities initialization.\n");
303 /* Make it the current GL context. */
304 if (!context_set_current(NULL
))
306 ERR_(d3d_caps
)("Failed to clear current D3D context.\n");
309 if (!pwglMakeCurrent(ctx
->dc
, ctx
->gl_ctx
))
311 ERR_(d3d_caps
)("Failed to make fake GL context current.\n");
318 if (ctx
->gl_ctx
) pwglDeleteContext(ctx
->gl_ctx
);
320 if (ctx
->dc
) ReleaseDC(ctx
->wnd
, ctx
->dc
);
322 if (ctx
->wnd
) DestroyWindow(ctx
->wnd
);
324 if (ctx
->restore_gl_ctx
&& !pwglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
326 ERR_(d3d_caps
)("Failed to restore previous GL context.\n");
332 /* Adjust the amount of used texture memory */
333 unsigned int WineD3DAdapterChangeGLRam(struct wined3d_device
*device
, int glram
)
335 struct wined3d_adapter
*adapter
= device
->adapter
;
337 adapter
->UsedTextureRam
+= glram
;
338 TRACE("Adjusted gl ram by %d to %d\n", glram
, adapter
->UsedTextureRam
);
339 return adapter
->UsedTextureRam
;
342 static void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
)
344 HeapFree(GetProcessHeap(), 0, adapter
->gl_info
.formats
);
345 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
348 ULONG CDECL
wined3d_incref(struct wined3d
*wined3d
)
350 ULONG refcount
= InterlockedIncrement(&wined3d
->ref
);
352 TRACE("%p increasing refcount to %u.\n", wined3d
, refcount
);
357 ULONG CDECL
wined3d_decref(struct wined3d
*wined3d
)
359 ULONG refcount
= InterlockedDecrement(&wined3d
->ref
);
361 TRACE("%p decreasing refcount to %u.\n", wined3d
, refcount
);
367 for (i
= 0; i
< wined3d
->adapter_count
; ++i
)
369 wined3d_adapter_cleanup(&wined3d
->adapters
[i
]);
371 HeapFree(GetProcessHeap(), 0, wined3d
);
377 /**********************************************************
378 * IWineD3D parts follows
379 **********************************************************/
381 /* GL locking is done by the caller */
382 static inline BOOL
test_arb_vs_offset_limit(const struct wined3d_gl_info
*gl_info
)
386 const char *testcode
=
388 "PARAM C[66] = { program.env[0..65] };\n"
390 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
391 "ARL A0.x, zero.x;\n"
392 "MOV result.position, C[A0.x + 65];\n"
396 GL_EXTCALL(glGenProgramsARB(1, &prog
));
398 ERR("Failed to create an ARB offset limit test program\n");
400 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
401 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
402 strlen(testcode
), testcode
));
405 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
406 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
408 } else TRACE("OpenGL implementation allows offsets > 63\n");
410 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
411 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
412 checkGLcall("ARB vp offset limit test cleanup");
417 static DWORD
ver_for_ext(GL_SupportedExt ext
)
420 for (i
= 0; i
< (sizeof(EXTENSION_MAP
) / sizeof(*EXTENSION_MAP
)); ++i
) {
421 if(EXTENSION_MAP
[i
].extension
== ext
) {
422 return EXTENSION_MAP
[i
].version
;
428 static BOOL
match_amd_r300_to_500(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
429 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
431 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
432 if (device
== CARD_AMD_RADEON_9500
) return TRUE
;
433 if (device
== CARD_AMD_RADEON_X700
) return TRUE
;
434 if (device
== CARD_AMD_RADEON_X1600
) return TRUE
;
438 static BOOL
match_geforce5(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
439 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
441 if (card_vendor
== HW_VENDOR_NVIDIA
)
443 if (device
== CARD_NVIDIA_GEFORCEFX_5200
||
444 device
== CARD_NVIDIA_GEFORCEFX_5600
||
445 device
== CARD_NVIDIA_GEFORCEFX_5800
)
453 static BOOL
match_apple(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
454 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
456 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
457 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
458 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
460 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
461 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
462 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
463 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
464 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
465 * the chance that other implementations support them is rather small since Win32 QuickTime uses
466 * DirectDraw, not OpenGL.
468 * This test has been moved into wined3d_guess_gl_vendor()
470 if (gl_vendor
== GL_VENDOR_APPLE
)
477 /* Context activation is done by the caller. */
478 static void test_pbo_functionality(struct wined3d_gl_info
*gl_info
)
480 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
481 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
482 * all the texture. This function detects this bug by its symptom and disables PBOs
485 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
486 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
487 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
488 * read back is compared to the original. If they are equal PBOs are assumed to work,
489 * otherwise the PBO extension is disabled. */
491 static const unsigned int pattern
[] =
493 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
494 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
495 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
496 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
498 unsigned int check
[sizeof(pattern
) / sizeof(pattern
[0])];
500 /* No PBO -> No point in testing them. */
501 if (!gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
]) return;
505 while (glGetError());
506 glGenTextures(1, &texture
);
507 glBindTexture(GL_TEXTURE_2D
, texture
);
509 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAX_LEVEL
, 0);
510 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 0);
511 checkGLcall("Specifying the PBO test texture");
513 GL_EXTCALL(glGenBuffersARB(1, &pbo
));
514 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, pbo
));
515 GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB
, sizeof(pattern
), pattern
, GL_STREAM_DRAW_ARB
));
516 checkGLcall("Specifying the PBO test pbo");
518 glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
519 checkGLcall("Loading the PBO test texture");
521 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, 0));
524 wglFinish(); /* just to be sure */
526 memset(check
, 0, sizeof(check
));
528 glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, check
);
529 checkGLcall("Reading back the PBO test texture");
531 glDeleteTextures(1, &texture
);
532 GL_EXTCALL(glDeleteBuffersARB(1, &pbo
));
533 checkGLcall("PBO test cleanup");
537 if (memcmp(check
, pattern
, sizeof(check
)))
539 WARN_(d3d_caps
)("PBO test failed, read back data doesn't match original.\n");
540 WARN_(d3d_caps
)("Disabling PBOs. This may result in slower performance.\n");
541 gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
] = FALSE
;
545 TRACE_(d3d_caps
)("PBO test successful.\n");
549 static BOOL
match_apple_intel(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
550 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
552 return (card_vendor
== HW_VENDOR_INTEL
) && (gl_vendor
== GL_VENDOR_APPLE
);
555 static BOOL
match_apple_nonr500ati(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
556 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
558 if (gl_vendor
!= GL_VENDOR_APPLE
) return FALSE
;
559 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
560 if (device
== CARD_AMD_RADEON_X1600
) return FALSE
;
564 static BOOL
match_fglrx(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
565 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
567 return gl_vendor
== GL_VENDOR_FGLRX
;
571 static BOOL
match_dx10_capable(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
572 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
574 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
575 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
576 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
577 * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
580 * dx10 cards usually have 64 varyings */
581 return gl_info
->limits
.glsl_varyings
> 44;
584 /* A GL context is provided by the caller */
585 static BOOL
match_allows_spec_alpha(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
586 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
591 if (!gl_info
->supported
[EXT_SECONDARY_COLOR
]) return FALSE
;
595 GL_EXTCALL(glSecondaryColorPointerEXT
)(4, GL_UNSIGNED_BYTE
, 4, data
);
596 error
= glGetError();
599 if(error
== GL_NO_ERROR
)
601 TRACE("GL Implementation accepts 4 component specular color pointers\n");
606 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
607 debug_glerror(error
));
612 static BOOL
match_apple_nvts(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
613 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
615 if (!match_apple(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
)) return FALSE
;
616 return gl_info
->supported
[NV_TEXTURE_SHADER
];
619 /* A GL context is provided by the caller */
620 static BOOL
match_broken_nv_clip(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
621 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
626 const char *testcode
=
628 "OPTION NV_vertex_program2;\n"
629 "MOV result.clip[0], 0.0;\n"
630 "MOV result.position, 0.0;\n"
633 if (!gl_info
->supported
[NV_VERTEX_PROGRAM2_OPTION
]) return FALSE
;
638 GL_EXTCALL(glGenProgramsARB(1, &prog
));
641 ERR("Failed to create the NVvp clip test program\n");
645 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
646 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
647 strlen(testcode
), testcode
));
648 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &pos
);
651 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
652 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
656 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
658 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
659 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
660 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
666 /* Context activation is done by the caller. */
667 static BOOL
match_fbo_tex_update(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
668 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
670 char data
[4 * 4 * 4];
674 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
) return FALSE
;
676 memset(data
, 0xcc, sizeof(data
));
680 glGenTextures(1, &tex
);
681 glBindTexture(GL_TEXTURE_2D
, tex
);
682 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
683 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
684 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
685 checkGLcall("glTexImage2D");
687 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
688 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
689 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
690 checkGLcall("glFramebufferTexture2D");
692 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
693 if (status
!= GL_FRAMEBUFFER_COMPLETE
) ERR("FBO status %#x\n", status
);
694 checkGLcall("glCheckFramebufferStatus");
696 memset(data
, 0x11, sizeof(data
));
697 glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
698 checkGLcall("glTexSubImage2D");
700 glClearColor(0.996f
, 0.729f
, 0.745f
, 0.792f
);
701 glClear(GL_COLOR_BUFFER_BIT
);
702 checkGLcall("glClear");
704 glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
705 checkGLcall("glGetTexImage");
707 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 0, 0);
708 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
709 glBindTexture(GL_TEXTURE_2D
, 0);
710 checkGLcall("glBindTexture");
712 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
713 glDeleteTextures(1, &tex
);
714 checkGLcall("glDeleteTextures");
718 return *(DWORD
*)data
== 0x11111111;
721 static void quirk_arb_constants(struct wined3d_gl_info
*gl_info
)
723 TRACE_(d3d_caps
)("Using ARB vs constant limit(=%u) for GLSL.\n", gl_info
->limits
.arb_vs_native_constants
);
724 gl_info
->limits
.glsl_vs_float_constants
= gl_info
->limits
.arb_vs_native_constants
;
725 TRACE_(d3d_caps
)("Using ARB ps constant limit(=%u) for GLSL.\n", gl_info
->limits
.arb_ps_native_constants
);
726 gl_info
->limits
.glsl_ps_float_constants
= gl_info
->limits
.arb_ps_native_constants
;
729 static void quirk_apple_glsl_constants(struct wined3d_gl_info
*gl_info
)
731 quirk_arb_constants(gl_info
);
732 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
733 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
734 * allow 48 different offsets or other helper immediate values. */
735 TRACE_(d3d_caps
)("Reserving 12 GLSL constants for compiler private use.\n");
736 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 12);
739 /* fglrx crashes with a very bad kernel panic if GL_POINT_SPRITE_ARB is set to GL_COORD_REPLACE_ARB
740 * on more than one texture unit. This means that the d3d9 visual point size test will cause a
741 * kernel panic on any machine running fglrx 9.3(latest that supports r300 to r500 cards). This
742 * quirk only enables point sprites on the first texture unit. This keeps point sprites working in
743 * most games, but avoids the crash
745 * A more sophisticated way would be to find all units that need texture coordinates and enable
746 * point sprites for one if only one is found, and software emulate point sprites in drawStridedSlow
747 * if more than one unit needs texture coordinates(This requires software ffp and vertex shaders though)
749 * Note that disabling the extension entirely does not gain predictability because there is no point
750 * sprite capability flag in d3d, so the potential rendering bugs are the same if we disable the extension. */
751 static void quirk_one_point_sprite(struct wined3d_gl_info
*gl_info
)
753 if (gl_info
->supported
[ARB_POINT_SPRITE
])
755 TRACE("Limiting point sprites to one texture unit.\n");
756 gl_info
->limits
.point_sprite_units
= 1;
760 static void quirk_amd_dx9(struct wined3d_gl_info
*gl_info
)
762 quirk_arb_constants(gl_info
);
764 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
765 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
766 * If real NP2 textures are used, the driver falls back to software. We could just remove the
767 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconventient
768 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
769 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
770 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
772 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
773 * has this extension promoted to core. The extension loading code sets this extension supported
774 * due to that, so this code works on fglrx as well. */
775 if(gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
777 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
778 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
779 gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
] = TRUE
;
782 /* fglrx has the same structural issues as the one described in quirk_apple_glsl_constants, although
783 * it is generally more efficient. Reserve just 8 constants. */
784 TRACE_(d3d_caps
)("Reserving 8 GLSL constants for compiler private use.\n");
785 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 8);
788 static void quirk_no_np2(struct wined3d_gl_info
*gl_info
)
790 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
791 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
792 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
793 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
794 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
795 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
797 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
798 * triggering the software fallback. There is not much we can do here apart from disabling the
799 * software-emulated extension and reenable ARB_tex_rect (which was previously disabled
800 * in wined3d_adapter_init_gl_caps).
801 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
802 * post-processing effects in the game "Max Payne 2").
803 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
804 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
805 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
806 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = TRUE
;
809 static void quirk_texcoord_w(struct wined3d_gl_info
*gl_info
)
811 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
812 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
813 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
814 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
815 * according to the spec.
817 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
818 * makes the shader slower and eats instruction slots which should be available to the d3d app.
820 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
821 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
822 * this workaround is activated on cards that do not need it, it won't break things, just affect
823 * performance negatively. */
824 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
825 gl_info
->quirks
|= WINED3D_QUIRK_SET_TEXCOORD_W
;
828 static void quirk_clip_varying(struct wined3d_gl_info
*gl_info
)
830 gl_info
->quirks
|= WINED3D_QUIRK_GLSL_CLIP_VARYING
;
833 static void quirk_allows_specular_alpha(struct wined3d_gl_info
*gl_info
)
835 gl_info
->quirks
|= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
;
838 static void quirk_apple_nvts(struct wined3d_gl_info
*gl_info
)
840 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
841 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
844 static void quirk_disable_nvvp_clip(struct wined3d_gl_info
*gl_info
)
846 gl_info
->quirks
|= WINED3D_QUIRK_NV_CLIP_BROKEN
;
849 static void quirk_fbo_tex_update(struct wined3d_gl_info
*gl_info
)
851 gl_info
->quirks
|= WINED3D_QUIRK_FBO_TEX_UPDATE
;
856 BOOL (*match
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
857 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
);
858 void (*apply
)(struct wined3d_gl_info
*gl_info
);
859 const char *description
;
862 static const struct driver_quirk quirk_table
[] =
865 match_amd_r300_to_500
,
867 "AMD GLSL constant and normalized texrect quirk"
869 /* MacOS advertises more GLSL vertex shader uniforms than supported by the hardware, and if more are
870 * used it falls back to software. While the compiler can detect if the shader uses all declared
871 * uniforms, the optimization fails if the shader uses relative addressing. So any GLSL shader
872 * using relative addressing falls back to software.
874 * ARB vp gives the correct amount of uniforms, so use it instead of GLSL. */
877 quirk_apple_glsl_constants
,
878 "Apple GLSL uniform override"
883 "Geforce 5 NP2 disable"
888 "Init texcoord .w for Apple Intel GPU driver"
891 match_apple_nonr500ati
,
893 "Init texcoord .w for Apple ATI >= r600 GPU driver"
897 quirk_one_point_sprite
,
898 "Fglrx point sprite crash workaround"
903 "Reserved varying for gl_ClipPos"
906 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
907 * GL implementations accept it. The Mac GL is the only implementation known to
910 * If we can pass 4 component specular colors, do it, because (a) we don't have
911 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
912 * passes specular alpha to the pixel shader if any is used. Otherwise the
913 * specular alpha is used to pass the fog coordinate, which we pass to opengl
914 * via GL_EXT_fog_coord.
916 match_allows_spec_alpha
,
917 quirk_allows_specular_alpha
,
918 "Allow specular alpha quirk"
921 /* The pixel formats provided by GL_NV_texture_shader are broken on OSX
926 "Apple NV_texture_shader disable"
929 match_broken_nv_clip
,
930 quirk_disable_nvvp_clip
,
931 "Apple NV_vertex_program clip bug quirk"
934 match_fbo_tex_update
,
935 quirk_fbo_tex_update
,
936 "FBO rebind for attachment updates"
940 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
941 * reporting a driver version is moot because we are not the Windows driver, and we have different
942 * bugs, features, etc.
944 * The driver version has the form "x.y.z.w".
946 * "x" is the Windows version the driver is meant for:
953 * "y" is the maximum Direct3D version the driver supports.
954 * y -> d3d version mapping:
963 * "z" is the subversion number.
965 * "w" is the vendor specific driver build number.
968 struct driver_version_information
970 enum wined3d_display_driver driver
;
971 enum wined3d_driver_model driver_model
;
972 const char *driver_name
; /* name of Windows driver */
973 WORD version
; /* version word ('y'), contained in low word of DriverVersion.HighPart */
974 WORD subversion
; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
975 WORD build
; /* build number ('w'), contained in low word of DriverVersion.LowPart */
978 /* The driver version table contains driver information for different devices on several OS versions. */
979 static const struct driver_version_information driver_version_table
[] =
982 * - Radeon HD2x00 (R600) and up supported by current drivers.
983 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
984 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
985 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
986 {DRIVER_AMD_RAGE_128PRO
, DRIVER_MODEL_NT5X
, "ati2dvaa.dll", 13, 3279, 0},
987 {DRIVER_AMD_R100
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6614},
988 {DRIVER_AMD_R300
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6764},
989 {DRIVER_AMD_R600
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 8681},
990 {DRIVER_AMD_R300
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
991 {DRIVER_AMD_R600
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
994 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
995 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
996 * igxprd32.dll but the GMA800 driver was never updated. */
997 {DRIVER_INTEL_GMA800
, DRIVER_MODEL_NT5X
, "ialmrnt5.dll", 14, 10, 3889},
998 {DRIVER_INTEL_GMA900
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4764},
999 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4926},
1000 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 5218},
1001 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 14, 10, 1504},
1002 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 15, 10, 1666},
1005 * - Geforce6 and newer cards are supported by the current driver (197.x) on XP-Win7
1006 * - GeforceFX support is up to 173.x on <= XP
1007 * - Geforce2MX/3/4 up to 96.x on <= XP
1008 * - TNT/Geforce1/2 up to 71.x on <= XP
1009 * All version numbers used below are from the Linux nvidia drivers. */
1010 {DRIVER_NVIDIA_TNT
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 7186},
1011 {DRIVER_NVIDIA_GEFORCE2MX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 9371},
1012 {DRIVER_NVIDIA_GEFORCEFX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 11, 7516},
1013 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 15, 12, 6658},
1014 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT6X
, "nvd3dum.dll", 15, 12, 6658},
1017 struct gpu_description
1019 WORD vendor
; /* reported PCI card vendor ID */
1020 WORD card
; /* reported PCI card device ID */
1021 const char *description
; /* Description of the card e.g. NVIDIA RIVA TNT */
1022 enum wined3d_display_driver driver
;
1023 unsigned int vidmem
;
1026 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1027 * found on a board containing a specific GPU. */
1028 static const struct gpu_description gpu_description_table
[] =
1031 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT
, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT
, 16 },
1032 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT2
, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1033 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE
, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT
, 32 },
1034 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2
, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1035 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2_MX
, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX
,32 },
1036 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE3
, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1037 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_MX
, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1038 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_TI4200
, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX
,64, },
1039 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5200
, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX
, 64 },
1040 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5600
, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX
, 128 },
1041 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5800
, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX
, 256 },
1042 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6200
, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6
, 64 },
1043 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6600GT
, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6
, 128 },
1044 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6800
, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6
, 128 },
1045 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7300
, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6
, 256 },
1046 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7400
, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6
, 256 },
1047 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7600
, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1048 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7800GT
, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1049 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8300GS
, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1050 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8400GS
, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1051 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600GT
, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1052 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600MGT
, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1053 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTS
, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE6
, 320 },
1054 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTX
, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE6
, 768 },
1055 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9200
, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE6
, 256 },
1056 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9400GT
, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1057 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9500GT
, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1058 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9600GT
, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE6
, 384 },
1059 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9800GT
, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1060 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_210
, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE6
, 512 },
1061 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT220
, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE6
, 512 },
1062 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT240
, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE6
, 512 },
1063 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX260
, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE6
, 1024},
1064 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX275
, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE6
, 896 },
1065 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX280
, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE6
, 1024},
1066 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT320M
, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1067 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT325M
, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1068 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT330
, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE6
, 1024},
1069 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS350M
, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1070 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT420
, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE6
, 2048},
1071 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT430
, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE6
, 1024},
1072 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT440
, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE6
, 1024},
1073 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS450
, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE6
, 1024},
1074 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460
, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE6
, 768 },
1075 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX465
, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE6
, 1024},
1076 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX470
, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE6
, 1280},
1077 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX480
, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE6
, 1536},
1078 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560
, "NVIDIA GeForce GTX 560 TI", DRIVER_NVIDIA_GEFORCE6
, 1024},
1079 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX570
, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE6
, 1280},
1080 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX580
, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE6
, 1536},
1083 {HW_VENDOR_AMD
, CARD_AMD_RAGE_128PRO
, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO
, 16 },
1084 {HW_VENDOR_AMD
, CARD_AMD_RADEON_7200
, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100
, 32 },
1085 {HW_VENDOR_AMD
, CARD_AMD_RADEON_8500
, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100
, 64 },
1086 {HW_VENDOR_AMD
, CARD_AMD_RADEON_9500
, "ATI Radeon 9500", DRIVER_AMD_R300
, 64 },
1087 {HW_VENDOR_AMD
, CARD_AMD_RADEON_XPRESS_200M
, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300
, 64 },
1088 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X700
, "ATI Radeon X700 SE", DRIVER_AMD_R300
, 128 },
1089 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X1600
, "ATI Radeon X1600 Series", DRIVER_AMD_R300
, 128 },
1090 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2350
, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600
, 256 },
1091 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2600
, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600
, 256 },
1092 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2900
, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600
, 512 },
1093 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD3200
, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600
, 128 },
1094 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4350
, "ATI Radeon HD 4350", DRIVER_AMD_R600
, 256 },
1095 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4600
, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600
, 512 },
1096 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4700
, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600
, 512 },
1097 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4800
, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600
, 512 },
1098 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5400
, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600
, 512 },
1099 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5600
, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600
, 512 },
1100 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5700
, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600
, 512 },
1101 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5800
, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600
, 1024},
1102 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5900
, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600
, 1024},
1103 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6310
, "AMD Radeon HD 6310 Graphics", DRIVER_AMD_R600
, 1024},
1104 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6800
, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600
, 1024},
1105 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6900
, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600
, 2048},
1107 {HW_VENDOR_INTEL
, CARD_INTEL_I830G
, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1108 {HW_VENDOR_INTEL
, CARD_INTEL_I855G
, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1109 {HW_VENDOR_INTEL
, CARD_INTEL_I865G
, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1110 {HW_VENDOR_INTEL
, CARD_INTEL_I915G
, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1111 {HW_VENDOR_INTEL
, CARD_INTEL_I915GM
, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1112 {HW_VENDOR_INTEL
, CARD_INTEL_I945GM
, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950
, 64 },
1113 {HW_VENDOR_INTEL
, CARD_INTEL_X3100
, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000
, 128},
1114 {HW_VENDOR_INTEL
, CARD_INTEL_GM45
, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000
, 512}
1117 static const struct driver_version_information
*get_driver_version_info(enum wined3d_display_driver driver
,
1118 enum wined3d_driver_model driver_model
)
1122 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver
, driver_model
);
1123 for (i
= 0; i
< (sizeof(driver_version_table
) / sizeof(driver_version_table
[0])); i
++)
1125 const struct driver_version_information
*entry
= &driver_version_table
[i
];
1127 if (entry
->driver
== driver
&& entry
->driver_model
== driver_model
)
1129 TRACE_(d3d_caps
)("Found driver '%s' version=%d subversion=%d build=%d\n",
1130 entry
->driver_name
, entry
->version
, entry
->subversion
, entry
->build
);
1138 static void init_driver_info(struct wined3d_driver_info
*driver_info
,
1139 enum wined3d_pci_vendor vendor
, enum wined3d_pci_device device
)
1141 OSVERSIONINFOW os_version
;
1142 WORD driver_os_version
;
1144 enum wined3d_display_driver driver
= DRIVER_UNKNOWN
;
1145 enum wined3d_driver_model driver_model
;
1146 const struct driver_version_information
*version_info
;
1148 if (wined3d_settings
.pci_vendor_id
!= PCI_VENDOR_NONE
)
1150 TRACE_(d3d_caps
)("Overriding PCI vendor ID with: %04x\n", wined3d_settings
.pci_vendor_id
);
1151 vendor
= wined3d_settings
.pci_vendor_id
;
1153 driver_info
->vendor
= vendor
;
1155 if (wined3d_settings
.pci_device_id
!= PCI_DEVICE_NONE
)
1157 TRACE_(d3d_caps
)("Overriding PCI device ID with: %04x\n", wined3d_settings
.pci_device_id
);
1158 device
= wined3d_settings
.pci_device_id
;
1160 driver_info
->device
= device
;
1162 /* Set a default amount of video memory (64MB). In general this code isn't used unless the user
1163 * overrides the pci ids to a card which is not in our database. */
1164 driver_info
->vidmem
= WINE_DEFAULT_VIDMEM
;
1166 memset(&os_version
, 0, sizeof(os_version
));
1167 os_version
.dwOSVersionInfoSize
= sizeof(os_version
);
1168 if (!GetVersionExW(&os_version
))
1170 ERR("Failed to get OS version, reporting 2000/XP.\n");
1171 driver_os_version
= 6;
1172 driver_model
= DRIVER_MODEL_NT5X
;
1176 TRACE("OS version %u.%u.\n", os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1177 switch (os_version
.dwMajorVersion
)
1180 /* If needed we could distinguish between 9x and NT4, but this code won't make
1181 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1183 driver_os_version
= 4;
1184 driver_model
= DRIVER_MODEL_WIN9X
;
1188 driver_os_version
= 6;
1189 driver_model
= DRIVER_MODEL_NT5X
;
1193 if (os_version
.dwMinorVersion
== 0)
1195 driver_os_version
= 7;
1196 driver_model
= DRIVER_MODEL_NT6X
;
1200 if (os_version
.dwMinorVersion
> 1)
1202 FIXME("Unhandled OS version %u.%u, reporting Win 7.\n",
1203 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1205 driver_os_version
= 8;
1206 driver_model
= DRIVER_MODEL_NT6X
;
1211 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1212 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1213 driver_os_version
= 6;
1214 driver_model
= DRIVER_MODEL_NT5X
;
1219 /* When we reach this stage we always have a vendor or device id (it can be a default one).
1220 * This means that unless the ids are overriden, we will always find a GPU description. */
1221 for (i
= 0; i
< (sizeof(gpu_description_table
) / sizeof(gpu_description_table
[0])); i
++)
1223 if (vendor
== gpu_description_table
[i
].vendor
&& device
== gpu_description_table
[i
].card
)
1225 TRACE_(d3d_caps
)("Found card %04x:%04x in driver DB.\n", vendor
, device
);
1227 driver_info
->description
= gpu_description_table
[i
].description
;
1228 driver_info
->vidmem
= gpu_description_table
[i
].vidmem
* 1024*1024;
1229 driver
= gpu_description_table
[i
].driver
;
1234 if (wined3d_settings
.emulated_textureram
)
1236 TRACE_(d3d_caps
)("Overriding amount of video memory with: %d byte\n", wined3d_settings
.emulated_textureram
);
1237 driver_info
->vidmem
= wined3d_settings
.emulated_textureram
;
1240 /* Try to obtain driver version information for the current Windows version. This fails in
1242 * - the gpu is not available on the currently selected OS version:
1243 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1244 * version information for the current Windows version is returned instead of faked info.
1245 * We do the same and assume the default Windows version to emulate is WinXP.
1247 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1248 * For now return the XP driver info. Perhaps later on we should return VESA.
1250 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1251 * This could be an indication that our database is not up to date, so this should be fixed.
1253 version_info
= get_driver_version_info(driver
, driver_model
);
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 version_info
= get_driver_version_info(driver
, DRIVER_MODEL_NT5X
);
1265 driver_info
->name
= version_info
->driver_name
;
1266 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1267 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1271 driver_info
->description
= "Direct3D HAL";
1272 driver_info
->name
= "Display";
1273 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, 15);
1274 driver_info
->version_low
= MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1276 FIXME("Unable to find a driver/device info for vendor_id=%#x device_id=%#x for driver_model=%d\n",
1277 vendor
, device
, driver_model
);
1281 TRACE_(d3d_caps
)("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1282 driver_info
->version_high
, driver_info
->version_low
);
1285 /* Context activation is done by the caller. */
1286 static void fixup_extensions(struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
1287 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
1291 for (i
= 0; i
< (sizeof(quirk_table
) / sizeof(*quirk_table
)); ++i
)
1293 if (!quirk_table
[i
].match(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
)) continue;
1294 TRACE_(d3d_caps
)("Applying driver quirk \"%s\".\n", quirk_table
[i
].description
);
1295 quirk_table
[i
].apply(gl_info
);
1298 /* Find out if PBOs work as they are supposed to. */
1299 test_pbo_functionality(gl_info
);
1302 static DWORD
wined3d_parse_gl_version(const char *gl_version
)
1304 const char *ptr
= gl_version
;
1308 if (major
<= 0) ERR_(d3d_caps
)("Invalid opengl major version: %d.\n", major
);
1310 while (isdigit(*ptr
)) ++ptr
;
1311 if (*ptr
++ != '.') ERR_(d3d_caps
)("Invalid opengl version string: %s.\n", debugstr_a(gl_version
));
1315 TRACE_(d3d_caps
)("Found OpenGL version: %d.%d.\n", major
, minor
);
1317 return MAKEDWORD_VERSION(major
, minor
);
1320 static enum wined3d_gl_vendor
wined3d_guess_gl_vendor(struct wined3d_gl_info
*gl_info
, const char *gl_vendor_string
, const char *gl_renderer
)
1323 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1324 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1325 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1327 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1328 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1329 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1330 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1331 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1332 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1333 * DirectDraw, not OpenGL. */
1334 if (gl_info
->supported
[APPLE_FENCE
]
1335 && gl_info
->supported
[APPLE_CLIENT_STORAGE
]
1336 && gl_info
->supported
[APPLE_FLUSH_RENDER
]
1337 && gl_info
->supported
[APPLE_YCBCR_422
])
1338 return GL_VENDOR_APPLE
;
1340 if (strstr(gl_vendor_string
, "NVIDIA"))
1341 return GL_VENDOR_NVIDIA
;
1343 if (strstr(gl_vendor_string
, "ATI"))
1344 return GL_VENDOR_FGLRX
;
1346 if (strstr(gl_vendor_string
, "Intel(R)")
1347 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1348 || strstr(gl_renderer
, "Intel")
1349 || strstr(gl_vendor_string
, "Intel Inc."))
1350 return GL_VENDOR_INTEL
;
1352 if (strstr(gl_vendor_string
, "Mesa")
1353 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1354 || strstr(gl_vendor_string
, "DRI R300 Project")
1355 || strstr(gl_vendor_string
, "X.Org R300 Project")
1356 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1357 || strstr(gl_vendor_string
, "VMware, Inc.")
1358 || strstr(gl_renderer
, "Mesa")
1359 || strstr(gl_renderer
, "Gallium"))
1360 return GL_VENDOR_MESA
;
1362 FIXME_(d3d_caps
)("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1363 debugstr_a(gl_vendor_string
));
1365 return GL_VENDOR_UNKNOWN
;
1368 static enum wined3d_pci_vendor
wined3d_guess_card_vendor(const char *gl_vendor_string
, const char *gl_renderer
)
1370 if (strstr(gl_vendor_string
, "NVIDIA")
1371 || strstr(gl_vendor_string
, "nouveau"))
1372 return HW_VENDOR_NVIDIA
;
1374 if (strstr(gl_vendor_string
, "ATI")
1375 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1376 || strstr(gl_vendor_string
, "X.Org R300 Project")
1377 || strstr(gl_renderer
, "AMD")
1378 || strstr(gl_renderer
, "R100")
1379 || strstr(gl_renderer
, "R200")
1380 || strstr(gl_renderer
, "R300")
1381 || strstr(gl_renderer
, "R600")
1382 || strstr(gl_renderer
, "R700"))
1383 return HW_VENDOR_AMD
;
1385 if (strstr(gl_vendor_string
, "Intel(R)")
1386 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1387 || strstr(gl_renderer
, "Intel")
1388 || strstr(gl_vendor_string
, "Intel Inc."))
1389 return HW_VENDOR_INTEL
;
1391 if (strstr(gl_vendor_string
, "Mesa")
1392 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1393 || strstr(gl_vendor_string
, "VMware, Inc."))
1394 return HW_VENDOR_SOFTWARE
;
1396 FIXME_(d3d_caps
)("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string
));
1398 return HW_VENDOR_NVIDIA
;
1401 static UINT
d3d_level_from_gl_info(const struct wined3d_gl_info
*gl_info
)
1405 if (gl_info
->supported
[ARB_MULTITEXTURE
])
1407 if (gl_info
->supported
[ARB_TEXTURE_COMPRESSION
]
1408 && gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
]
1409 && gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
1411 if (level
== 7 && gl_info
->supported
[ARB_MULTISAMPLE
]
1412 && gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
1414 if (level
== 8 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]
1415 && gl_info
->supported
[ARB_VERTEX_SHADER
])
1417 if (level
== 9 && gl_info
->supported
[EXT_GPU_SHADER4
])
1423 static enum wined3d_pci_device
select_card_nvidia_binary(const struct wined3d_gl_info
*gl_info
,
1424 const char *gl_renderer
)
1426 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
1429 if (d3d_level
>= 10)
1433 const char *renderer
;
1434 enum wined3d_pci_device id
;
1438 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580
}, /* Geforce 500 - highend */
1439 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570
}, /* Geforce 500 - midend high */
1440 {"GTX 560 TI", CARD_NVIDIA_GEFORCE_GTX560
}, /* Geforce 500 - midend */
1441 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480
}, /* Geforce 400 - highend */
1442 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470
}, /* Geforce 400 - midend high */
1443 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465
}, /* Geforce 400 - midend */
1444 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460
}, /* Geforce 400 - midend */
1445 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450
}, /* Geforce 400 - midend low */
1446 {"GT 440", CARD_NVIDIA_GEFORCE_GT440
}, /* Geforce 400 - lowend */
1447 {"GT 430", CARD_NVIDIA_GEFORCE_GT430
}, /* Geforce 400 - lowend */
1448 {"GT 420", CARD_NVIDIA_GEFORCE_GT420
}, /* Geforce 400 - lowend */
1449 {"GT 330", CARD_NVIDIA_GEFORCE_GT330
}, /* Geforce 300 - highend */
1450 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1451 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1452 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1453 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1454 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M
}, /* Geforce 300 - midend mobile */
1455 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1456 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1457 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1458 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275
}, /* Geforce 200 - midend high */
1459 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260
}, /* Geforce 200 - midend */
1460 {"GT 240", CARD_NVIDIA_GEFORCE_GT240
}, /* Geforce 200 - midend */
1461 {"GT 220", CARD_NVIDIA_GEFORCE_GT220
}, /* Geforce 200 - lowend */
1462 {"Geforce 310", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1463 {"Geforce 305", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1464 {"Geforce 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1465 {"G 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1466 {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1467 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1468 {"9800", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1469 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1470 {"9600", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1471 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1472 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1473 {"9500", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1474 {"9400", CARD_NVIDIA_GEFORCE_9400GT
}, /* Geforce 9 - lowend */
1475 {"9300", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1476 {"9200", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1477 {"9100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1478 {"G 100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1479 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX
}, /* Geforce 8 - highend high */
1480 {"8800", CARD_NVIDIA_GEFORCE_8800GTS
}, /* Geforce 8 - highend */
1481 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1482 {"8700", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1483 {"8600", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1484 {"8500", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1485 {"8400", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1486 {"8300", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1487 {"8200", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1488 {"8100", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1491 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1493 if (strstr(gl_renderer
, cards
[i
].renderer
))
1497 /* Geforce8-compatible fall back if the GPU is not in the list yet */
1498 return CARD_NVIDIA_GEFORCE_8300GS
;
1501 /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
1502 * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
1504 if (d3d_level
>= 9 && gl_info
->supported
[NV_VERTEX_PROGRAM3
])
1508 const char *renderer
;
1509 enum wined3d_pci_device id
;
1513 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1514 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1515 {"7950", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1516 {"7900", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1517 {"7800", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1518 {"7700", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1519 {"7600", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1520 {"7400", CARD_NVIDIA_GEFORCE_7400
}, /* Geforce 7 - lower medium */
1521 {"7300", CARD_NVIDIA_GEFORCE_7300
}, /* Geforce 7 - lowend */
1522 {"6800", CARD_NVIDIA_GEFORCE_6800
}, /* Geforce 6 - highend */
1523 {"6700", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1524 {"6610", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1525 {"6600", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1528 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1530 if (strstr(gl_renderer
, cards
[i
].renderer
))
1534 /* Geforce 6/7 - lowend */
1535 return CARD_NVIDIA_GEFORCE_6200
; /* Geforce 6100/6150/6200/7300/7400/7500 */
1540 /* GeforceFX - highend */
1541 if (strstr(gl_renderer
, "5800")
1542 || strstr(gl_renderer
, "5900")
1543 || strstr(gl_renderer
, "5950")
1544 || strstr(gl_renderer
, "Quadro FX"))
1546 return CARD_NVIDIA_GEFORCEFX_5800
;
1549 /* GeforceFX - midend */
1550 if (strstr(gl_renderer
, "5600")
1551 || strstr(gl_renderer
, "5650")
1552 || strstr(gl_renderer
, "5700")
1553 || strstr(gl_renderer
, "5750"))
1555 return CARD_NVIDIA_GEFORCEFX_5600
;
1558 /* GeforceFX - lowend */
1559 return CARD_NVIDIA_GEFORCEFX_5200
; /* GeforceFX 5100/5200/5250/5300/5500 */
1564 if (strstr(gl_renderer
, "GeForce4 Ti") || strstr(gl_renderer
, "Quadro4"))
1566 return CARD_NVIDIA_GEFORCE4_TI4200
; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
1569 return CARD_NVIDIA_GEFORCE3
; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
1574 if (strstr(gl_renderer
, "GeForce4 MX"))
1576 return CARD_NVIDIA_GEFORCE4_MX
; /* MX420/MX440/MX460/MX4000 */
1579 if (strstr(gl_renderer
, "GeForce2 MX") || strstr(gl_renderer
, "Quadro2 MXR"))
1581 return CARD_NVIDIA_GEFORCE2_MX
; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
1584 if (strstr(gl_renderer
, "GeForce2") || strstr(gl_renderer
, "Quadro2"))
1586 return CARD_NVIDIA_GEFORCE2
; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
1589 return CARD_NVIDIA_GEFORCE
; /* Geforce 256/DDR, Quadro */
1592 if (strstr(gl_renderer
, "TNT2"))
1594 return CARD_NVIDIA_RIVA_TNT2
; /* Riva TNT2 standard/M64/Pro/Ultra */
1597 return CARD_NVIDIA_RIVA_TNT
; /* Riva TNT, Vanta */
1600 static enum wined3d_pci_device
select_card_amd_binary(const struct wined3d_gl_info
*gl_info
,
1601 const char *gl_renderer
)
1603 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
1605 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1607 * Beware: renderer string do not match exact card model,
1608 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1609 if (d3d_level
>= 10)
1615 const char *renderer
;
1616 enum wined3d_pci_device id
;
1621 {"HD 5870", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS PRO */
1622 {"HD 5850", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS XT */
1623 {"HD 5800", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1624 {"HD 5770", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER XT */
1625 {"HD 5750", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER LE */
1626 {"HD 5700", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1627 {"HD 5670", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD XT */
1628 {"HD 5570", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1629 {"HD 5550", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1630 {"HD 5450", CARD_AMD_RADEON_HD5400
}, /* Radeon EG CEDAR PRO */
1632 {"HD 4890", CARD_AMD_RADEON_HD4800
}, /* Radeon RV790 */
1633 {"HD 4870", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1634 {"HD 4850", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1635 {"HD 4830", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1636 {"HD 4800", CARD_AMD_RADEON_HD4800
}, /* Radeon RV7xx HD48xx generic renderer string */
1637 {"HD 4770", CARD_AMD_RADEON_HD4700
}, /* Radeon RV740 */
1638 {"HD 4700", CARD_AMD_RADEON_HD4700
}, /* Radeon RV7xx HD47xx generic renderer string */
1639 {"HD 4670", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1640 {"HD 4650", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1641 {"HD 4600", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1642 {"HD 4550", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1643 {"HD 4350", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1644 /* R600/R700 integrated */
1645 {"HD 3300", CARD_AMD_RADEON_HD3200
},
1646 {"HD 3200", CARD_AMD_RADEON_HD3200
},
1647 {"HD 3100", CARD_AMD_RADEON_HD3200
},
1649 {"HD 3870", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1650 {"HD 3850", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1651 {"HD 2900", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1652 {"HD 3830", CARD_AMD_RADEON_HD2600
}, /* China-only midend */
1653 {"HD 3690", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1654 {"HD 3650", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1655 {"HD 2600", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1656 {"HD 3470", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1657 {"HD 3450", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1658 {"HD 3430", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1659 {"HD 3400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1660 {"HD 2400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1661 {"HD 2350", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1664 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1666 if (strstr(gl_renderer
, cards
[i
].renderer
))
1670 /* Default for when no GPU has been found */
1671 return CARD_AMD_RADEON_HD3200
;
1677 if (strstr(gl_renderer
, "X1600")
1678 || strstr(gl_renderer
, "X1650")
1679 || strstr(gl_renderer
, "X1800")
1680 || strstr(gl_renderer
, "X1900")
1681 || strstr(gl_renderer
, "X1950"))
1683 return CARD_AMD_RADEON_X1600
;
1686 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1687 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1688 if (strstr(gl_renderer
, "X700")
1689 || strstr(gl_renderer
, "X800")
1690 || strstr(gl_renderer
, "X850")
1691 || strstr(gl_renderer
, "X1300")
1692 || strstr(gl_renderer
, "X1400")
1693 || strstr(gl_renderer
, "X1450")
1694 || strstr(gl_renderer
, "X1550")
1695 || strstr(gl_renderer
, "X2300")
1696 || strstr(gl_renderer
, "X2500")
1697 || strstr(gl_renderer
, "HD 2300")
1700 return CARD_AMD_RADEON_X700
;
1703 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1704 if (strstr(gl_renderer
, "Radeon Xpress"))
1706 return CARD_AMD_RADEON_XPRESS_200M
;
1710 return CARD_AMD_RADEON_9500
; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
1714 return CARD_AMD_RADEON_8500
; /* Radeon 8500/9000/9100/9200/9300 */
1717 return CARD_AMD_RADEON_7200
; /* Radeon 7000/7100/7200/7500 */
1719 return CARD_AMD_RAGE_128PRO
;
1722 static enum wined3d_pci_device
select_card_intel(const struct wined3d_gl_info
*gl_info
,
1723 const char *gl_renderer
)
1725 if (strstr(gl_renderer
, "GM45")) return CARD_INTEL_GM45
;
1726 if (strstr(gl_renderer
, "X3100") || strstr(gl_renderer
, "965GM"))
1728 /* MacOS calls the card GMA X3100, otherwise known as GM965/GL960 */
1729 return CARD_INTEL_X3100
;
1732 if (strstr(gl_renderer
, "GMA 950") || strstr(gl_renderer
, "945GM"))
1734 /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
1735 return CARD_INTEL_I945GM
;
1738 if (strstr(gl_renderer
, "915GM")) return CARD_INTEL_I915GM
;
1739 if (strstr(gl_renderer
, "915G")) return CARD_INTEL_I915G
;
1740 if (strstr(gl_renderer
, "865G")) return CARD_INTEL_I865G
;
1741 if (strstr(gl_renderer
, "855G")) return CARD_INTEL_I855G
;
1742 if (strstr(gl_renderer
, "830G")) return CARD_INTEL_I830G
;
1743 return CARD_INTEL_I915G
;
1747 static enum wined3d_pci_device
select_card_amd_mesa(const struct wined3d_gl_info
*gl_info
,
1748 const char *gl_renderer
)
1753 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1755 * Beware: renderer string do not match exact card model,
1756 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1757 if (strstr(gl_renderer
, "Gallium"))
1759 /* 20101109 - These are never returned by current Gallium radeon
1760 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
1762 * These are returned but not handled: RC410, RV380. */
1765 const char *renderer
;
1766 enum wined3d_pci_device id
;
1770 /* Northern Islands */
1771 {"CAYMAN", CARD_AMD_RADEON_HD6900
},
1772 {"BARTS", CARD_AMD_RADEON_HD6800
},
1773 {"PALM", CARD_AMD_RADEON_HD6310
},
1775 {"HEMLOCK", CARD_AMD_RADEON_HD5900
},
1776 {"CYPRESS", CARD_AMD_RADEON_HD5800
},
1777 {"JUNIPER", CARD_AMD_RADEON_HD5700
},
1778 {"REDWOOD", CARD_AMD_RADEON_HD5600
},
1779 {"CEDAR", CARD_AMD_RADEON_HD5400
},
1781 {"R700", CARD_AMD_RADEON_HD4800
}, /* HD4800 - highend */
1782 {"RV790", CARD_AMD_RADEON_HD4800
},
1783 {"RV770", CARD_AMD_RADEON_HD4800
},
1784 {"RV740", CARD_AMD_RADEON_HD4700
}, /* HD4700 - midend */
1785 {"RV730", CARD_AMD_RADEON_HD4600
}, /* HD4600 - midend */
1786 {"RV710", CARD_AMD_RADEON_HD4350
}, /* HD4500/HD4350 - lowend */
1787 /* R600/R700 integrated */
1788 {"RS880", CARD_AMD_RADEON_HD3200
},
1789 {"RS780", CARD_AMD_RADEON_HD3200
},
1791 {"R680", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1792 {"R600", CARD_AMD_RADEON_HD2900
},
1793 {"RV670", CARD_AMD_RADEON_HD2900
},
1794 {"RV635", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1795 {"RV630", CARD_AMD_RADEON_HD2600
},
1796 {"RV620", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1797 {"RV610", CARD_AMD_RADEON_HD2350
},
1799 {"R580", CARD_AMD_RADEON_X1600
},
1800 {"R520", CARD_AMD_RADEON_X1600
},
1801 {"RV570", CARD_AMD_RADEON_X1600
},
1802 {"RV560", CARD_AMD_RADEON_X1600
},
1803 {"RV535", CARD_AMD_RADEON_X1600
},
1804 {"RV530", CARD_AMD_RADEON_X1600
},
1805 {"RV516", CARD_AMD_RADEON_X700
}, /* X700 is actually R400. */
1806 {"RV515", CARD_AMD_RADEON_X700
},
1808 {"R481", CARD_AMD_RADEON_X700
},
1809 {"R480", CARD_AMD_RADEON_X700
},
1810 {"R430", CARD_AMD_RADEON_X700
},
1811 {"R423", CARD_AMD_RADEON_X700
},
1812 {"R420", CARD_AMD_RADEON_X700
},
1813 {"R410", CARD_AMD_RADEON_X700
},
1814 {"RV410", CARD_AMD_RADEON_X700
},
1815 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400MHz */
1816 {"RS740", CARD_AMD_RADEON_XPRESS_200M
},
1817 {"RS690", CARD_AMD_RADEON_XPRESS_200M
},
1818 {"RS600", CARD_AMD_RADEON_XPRESS_200M
},
1819 {"RS485", CARD_AMD_RADEON_XPRESS_200M
},
1820 {"RS482", CARD_AMD_RADEON_XPRESS_200M
},
1821 {"RS480", CARD_AMD_RADEON_XPRESS_200M
},
1822 {"RS400", CARD_AMD_RADEON_XPRESS_200M
},
1824 {"R360", CARD_AMD_RADEON_9500
},
1825 {"R350", CARD_AMD_RADEON_9500
},
1826 {"R300", CARD_AMD_RADEON_9500
},
1827 {"RV370", CARD_AMD_RADEON_9500
},
1828 {"RV360", CARD_AMD_RADEON_9500
},
1829 {"RV351", CARD_AMD_RADEON_9500
},
1830 {"RV350", CARD_AMD_RADEON_9500
},
1833 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1835 if (strstr(gl_renderer
, cards
[i
].renderer
))
1840 d3d_level
= d3d_level_from_gl_info(gl_info
);
1845 const char *renderer
;
1846 enum wined3d_pci_device id
;
1851 {"(R700", CARD_AMD_RADEON_HD4800
}, /* HD4800 - highend */
1852 {"(RV790", CARD_AMD_RADEON_HD4800
},
1853 {"(RV770", CARD_AMD_RADEON_HD4800
},
1854 {"(RV740", CARD_AMD_RADEON_HD4700
}, /* HD4700 - midend */
1855 {"(RV730", CARD_AMD_RADEON_HD4600
}, /* HD4600 - midend */
1856 {"(RV710", CARD_AMD_RADEON_HD4350
}, /* HD4500/HD4350 - lowend */
1857 /* R600/R700 integrated */
1858 {"RS880", CARD_AMD_RADEON_HD3200
},
1859 {"RS780", CARD_AMD_RADEON_HD3200
},
1861 {"(R680", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1862 {"(R600", CARD_AMD_RADEON_HD2900
},
1863 {"(RV670", CARD_AMD_RADEON_HD2900
},
1864 {"(RV635", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1865 {"(RV630", CARD_AMD_RADEON_HD2600
},
1866 {"(RV620", CARD_AMD_RADEON_HD2350
}, /* HD2300/HD2400/HD3400 - lowend */
1867 {"(RV610", CARD_AMD_RADEON_HD2350
},
1870 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1872 if (strstr(gl_renderer
, cards
[i
].renderer
))
1878 return CARD_AMD_RADEON_8500
; /* Radeon 8500/9000/9100/9200/9300 */
1881 return CARD_AMD_RADEON_7200
; /* Radeon 7000/7100/7200/7500 */
1883 return CARD_AMD_RAGE_128PRO
;
1886 static enum wined3d_pci_device
select_card_nvidia_mesa(const struct wined3d_gl_info
*gl_info
,
1887 const char *gl_renderer
)
1891 if (strstr(gl_renderer
, "Gallium"))
1897 const char *renderer
;
1898 enum wined3d_pci_device id
;
1902 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570
},
1903 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460
},
1904 {"NVC3", CARD_NVIDIA_GEFORCE_GT440
},
1905 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480
},
1906 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M
},
1907 {"NVAC", CARD_NVIDIA_GEFORCE_8200
},
1908 {"NVAA", CARD_NVIDIA_GEFORCE_8200
},
1909 {"NVA8", CARD_NVIDIA_GEFORCE_210
},
1910 {"NVA5", CARD_NVIDIA_GEFORCE_GT220
},
1911 {"NVA3", CARD_NVIDIA_GEFORCE_GT240
},
1912 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280
},
1913 {"NV98", CARD_NVIDIA_GEFORCE_9200
},
1914 {"NV96", CARD_NVIDIA_GEFORCE_9400GT
},
1915 {"NV94", CARD_NVIDIA_GEFORCE_9600GT
},
1916 {"NV92", CARD_NVIDIA_GEFORCE_9800GT
},
1917 {"NV86", CARD_NVIDIA_GEFORCE_8500GT
},
1918 {"NV84", CARD_NVIDIA_GEFORCE_8600GT
},
1919 {"NV68", CARD_NVIDIA_GEFORCE_6200
}, /* 7050 */
1920 {"NV67", CARD_NVIDIA_GEFORCE_6200
}, /* 7000M */
1921 {"NV63", CARD_NVIDIA_GEFORCE_6200
}, /* 7100 */
1922 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX
},
1923 {"NV4E", CARD_NVIDIA_GEFORCE_6200
}, /* 6100 Go / 6150 Go */
1924 {"NV4C", CARD_NVIDIA_GEFORCE_6200
}, /* 6150SE */
1925 {"NV4B", CARD_NVIDIA_GEFORCE_7600
},
1926 {"NV4A", CARD_NVIDIA_GEFORCE_6200
},
1927 {"NV49", CARD_NVIDIA_GEFORCE_7800GT
}, /* 7900 */
1928 {"NV47", CARD_NVIDIA_GEFORCE_7800GT
},
1929 {"NV46", CARD_NVIDIA_GEFORCE_7400
},
1930 {"NV45", CARD_NVIDIA_GEFORCE_6800
},
1931 {"NV44", CARD_NVIDIA_GEFORCE_6200
},
1932 {"NV43", CARD_NVIDIA_GEFORCE_6600GT
},
1933 {"NV42", CARD_NVIDIA_GEFORCE_6800
},
1934 {"NV41", CARD_NVIDIA_GEFORCE_6800
},
1935 {"NV40", CARD_NVIDIA_GEFORCE_6800
},
1936 {"NV38", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5950 Ultra */
1937 {"NV36", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5700/5750 */
1938 {"NV35", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5900 */
1939 {"NV34", CARD_NVIDIA_GEFORCEFX_5200
},
1940 {"NV31", CARD_NVIDIA_GEFORCEFX_5600
},
1941 {"NV30", CARD_NVIDIA_GEFORCEFX_5800
},
1942 {"NV28", CARD_NVIDIA_GEFORCE4_TI4200
},
1943 {"NV25", CARD_NVIDIA_GEFORCE4_TI4200
},
1944 {"NV20", CARD_NVIDIA_GEFORCE3
},
1945 {"NV1F", CARD_NVIDIA_GEFORCE4_MX
}, /* GF4 MX IGP */
1946 {"NV1A", CARD_NVIDIA_GEFORCE2
}, /* GF2 IGP */
1947 {"NV18", CARD_NVIDIA_GEFORCE4_MX
},
1948 {"NV17", CARD_NVIDIA_GEFORCE4_MX
},
1949 {"NV16", CARD_NVIDIA_GEFORCE2
},
1950 {"NV15", CARD_NVIDIA_GEFORCE2
},
1951 {"NV11", CARD_NVIDIA_GEFORCE2_MX
},
1952 {"NV10", CARD_NVIDIA_GEFORCE
},
1953 {"NV05", CARD_NVIDIA_RIVA_TNT2
},
1954 {"NV04", CARD_NVIDIA_RIVA_TNT
},
1955 {"NV03", CARD_NVIDIA_RIVA_128
},
1958 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1960 if (strstr(gl_renderer
, cards
[i
].renderer
))
1965 FIXME_(d3d_caps
)("Unknown renderer %s.\n", debugstr_a(gl_renderer
));
1967 d3d_level
= d3d_level_from_gl_info(gl_info
);
1969 return CARD_NVIDIA_GEFORCEFX_5600
;
1971 return CARD_NVIDIA_GEFORCE3
;
1973 return CARD_NVIDIA_GEFORCE
;
1975 return CARD_NVIDIA_RIVA_TNT
;
1976 return CARD_NVIDIA_RIVA_128
;
1980 struct vendor_card_selection
1982 enum wined3d_gl_vendor gl_vendor
;
1983 enum wined3d_pci_vendor card_vendor
;
1984 const char *description
; /* Description of the card selector i.e. Apple OS/X Intel */
1985 enum wined3d_pci_device (*select_card
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
);
1988 static const struct vendor_card_selection vendor_card_select_table
[] =
1990 {GL_VENDOR_NVIDIA
, HW_VENDOR_NVIDIA
, "Nvidia binary driver", select_card_nvidia_binary
},
1991 {GL_VENDOR_APPLE
, HW_VENDOR_NVIDIA
, "Apple OSX NVidia binary driver", select_card_nvidia_binary
},
1992 {GL_VENDOR_APPLE
, HW_VENDOR_AMD
, "Apple OSX AMD/ATI binary driver", select_card_amd_binary
},
1993 {GL_VENDOR_APPLE
, HW_VENDOR_INTEL
, "Apple OSX Intel binary driver", select_card_intel
},
1994 {GL_VENDOR_FGLRX
, HW_VENDOR_AMD
, "AMD/ATI binary driver", select_card_amd_binary
},
1995 {GL_VENDOR_MESA
, HW_VENDOR_AMD
, "Mesa AMD/ATI driver", select_card_amd_mesa
},
1996 {GL_VENDOR_MESA
, HW_VENDOR_NVIDIA
, "Mesa Nouveau driver", select_card_nvidia_mesa
},
1997 {GL_VENDOR_MESA
, HW_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
},
1998 {GL_VENDOR_INTEL
, HW_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
}
2002 static enum wined3d_pci_device
wined3d_guess_card(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
2003 enum wined3d_gl_vendor
*gl_vendor
, enum wined3d_pci_vendor
*card_vendor
)
2007 /* Above is a list of Nvidia and ATI GPUs. Both vendors have dozens of
2008 * different GPUs with roughly the same features. In most cases GPUs from a
2009 * certain family differ in clockspeeds, the amount of video memory and the
2010 * number of shader pipelines.
2012 * A Direct3D device object contains the PCI id (vendor + device) of the
2013 * videocard which is used for rendering. Various applications use this
2014 * information to get a rough estimation of the features of the card and
2015 * some might use it for enabling 3d effects only on certain types of
2016 * videocards. In some cases games might even use it to work around bugs
2017 * which happen on certain videocards/driver combinations. The problem is
2018 * that OpenGL only exposes a rendering string containing the name of the
2019 * videocard and not the PCI id.
2021 * Various games depend on the PCI id, so somehow we need to provide one.
2022 * A simple option is to parse the renderer string and translate this to
2023 * the right PCI id. This is a lot of work because there are more than 200
2024 * GPUs just for Nvidia. Various cards share the same renderer string, so
2025 * the amount of code might be 'small' but there are quite a number of
2026 * exceptions which would make this a pain to maintain. Another way would
2027 * be to query the PCI id from the operating system (assuming this is the
2028 * videocard which is used for rendering which is not always the case).
2029 * This would work but it is not very portable. Second it would not work
2030 * well in, let's say, a remote X situation in which the amount of 3d
2031 * features which can be used is limited.
2033 * As said most games only use the PCI id to get an indication of the
2034 * capabilities of the card. It doesn't really matter if the given id is
2035 * the correct one if we return the id of a card with similar 3d features.
2037 * The code below checks the OpenGL capabilities of a videocard and matches
2038 * that to a certain level of Direct3D functionality. Once a card passes
2039 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
2040 * least a GeforceFX. To give a better estimate we do a basic check on the
2041 * renderer string but if that won't pass we return a default card. This
2042 * way is better than maintaining a full card database as even without a
2043 * full database we can return a card with similar features. Second the
2044 * size of the database can be made quite small because when you know what
2045 * type of 3d functionality a card has, you know to which GPU family the
2046 * GPU must belong. Because of this you only have to check a small part of
2047 * the renderer string to distinguishes between different models from that
2050 * The code also selects a default amount of video memory which we will
2051 * use for an estimation of the amount of free texture memory. In case of
2052 * real D3D the amount of texture memory includes video memory and system
2053 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2054 * HyperMemory). We don't know how much system memory can be addressed by
2055 * the system but we can make a reasonable estimation about the amount of
2056 * video memory. If the value is slightly wrong it doesn't matter as we
2057 * didn't include AGP-like memory which makes the amount of addressable
2058 * memory higher and second OpenGL isn't that critical it moves to system
2059 * memory behind our backs if really needed. Note that the amount of video
2060 * memory can be overruled using a registry setting. */
2064 for (i
= 0; i
< (sizeof(vendor_card_select_table
) / sizeof(*vendor_card_select_table
)); ++i
)
2066 if ((vendor_card_select_table
[i
].gl_vendor
!= *gl_vendor
)
2067 || (vendor_card_select_table
[i
].card_vendor
!= *card_vendor
))
2069 TRACE_(d3d_caps
)("Applying card_selector \"%s\".\n", vendor_card_select_table
[i
].description
);
2070 return vendor_card_select_table
[i
].select_card(gl_info
, gl_renderer
);
2073 FIXME_(d3d_caps
)("No card selector available for GL vendor %d and card vendor %04x.\n",
2074 *gl_vendor
, *card_vendor
);
2076 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
2077 * for Nvidia was because the hardware and drivers they make are of good quality. This makes
2078 * them a good generic choice. */
2079 *card_vendor
= HW_VENDOR_NVIDIA
;
2080 d3d_level
= d3d_level_from_gl_info(gl_info
);
2082 return CARD_NVIDIA_GEFORCEFX_5600
;
2084 return CARD_NVIDIA_GEFORCE3
;
2086 return CARD_NVIDIA_GEFORCE
;
2088 return CARD_NVIDIA_RIVA_TNT
;
2089 return CARD_NVIDIA_RIVA_128
;
2092 static const struct fragment_pipeline
*select_fragment_implementation(struct wined3d_adapter
*adapter
)
2094 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
2095 int vs_selected_mode
, ps_selected_mode
;
2097 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2098 if ((ps_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_GLSL
)
2099 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]) return &arbfp_fragment_pipeline
;
2100 else if (ps_selected_mode
== SHADER_ATI
) return &atifs_fragment_pipeline
;
2101 else if (gl_info
->supported
[NV_REGISTER_COMBINERS
]
2102 && gl_info
->supported
[NV_TEXTURE_SHADER2
]) return &nvts_fragment_pipeline
;
2103 else if (gl_info
->supported
[NV_REGISTER_COMBINERS
]) return &nvrc_fragment_pipeline
;
2104 else return &ffp_fragment_pipeline
;
2107 static const struct wined3d_shader_backend_ops
*select_shader_backend(struct wined3d_adapter
*adapter
)
2109 int vs_selected_mode
, ps_selected_mode
;
2111 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2112 if (vs_selected_mode
== SHADER_GLSL
|| ps_selected_mode
== SHADER_GLSL
) return &glsl_shader_backend
;
2113 if (vs_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_ARB
) return &arb_program_shader_backend
;
2114 return &none_shader_backend
;
2117 static const struct blit_shader
*select_blit_implementation(struct wined3d_adapter
*adapter
)
2119 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
2120 int vs_selected_mode
, ps_selected_mode
;
2122 select_shader_mode(gl_info
, &ps_selected_mode
, &vs_selected_mode
);
2123 if ((ps_selected_mode
== SHADER_ARB
|| ps_selected_mode
== SHADER_GLSL
)
2124 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]) return &arbfp_blit
;
2125 else return &ffp_blit
;
2128 static void load_gl_funcs(struct wined3d_gl_info
*gl_info
, DWORD gl_version
)
2132 #define USE_GL_FUNC(type, pfn, ext, replace) \
2133 if (gl_info->supported[ext]) gl_info->pfn = (type)pwglGetProcAddress(#pfn); \
2134 else if ((ver = ver_for_ext(ext)) && ver <= gl_version) gl_info->pfn = (type)pwglGetProcAddress(#replace); \
2135 else gl_info->pfn = NULL;
2140 #define USE_GL_FUNC(type, pfn, ext, replace) gl_info->pfn = (type)pwglGetProcAddress(#pfn);
2145 /* Context activation is done by the caller. */
2146 static BOOL
wined3d_adapter_init_gl_caps(struct wined3d_adapter
*adapter
)
2148 struct wined3d_driver_info
*driver_info
= &adapter
->driver_info
;
2149 struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
2150 const char *GL_Extensions
= NULL
;
2151 const char *WGL_Extensions
= NULL
;
2152 const char *gl_vendor_str
, *gl_renderer_str
, *gl_version_str
;
2153 struct fragment_caps fragment_caps
;
2154 enum wined3d_gl_vendor gl_vendor
;
2155 enum wined3d_pci_vendor card_vendor
;
2156 enum wined3d_pci_device device
;
2158 GLfloat gl_floatv
[2];
2164 TRACE_(d3d_caps
)("(%p)\n", gl_info
);
2168 gl_renderer_str
= (const char *)glGetString(GL_RENDERER
);
2169 TRACE_(d3d_caps
)("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str
));
2170 if (!gl_renderer_str
)
2173 ERR_(d3d_caps
)("Received a NULL GL_RENDERER.\n");
2177 gl_vendor_str
= (const char *)glGetString(GL_VENDOR
);
2178 TRACE_(d3d_caps
)("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str
));
2182 ERR_(d3d_caps
)("Received a NULL GL_VENDOR.\n");
2186 /* Parse the GL_VERSION field into major and minor information */
2187 gl_version_str
= (const char *)glGetString(GL_VERSION
);
2188 TRACE_(d3d_caps
)("GL_VERSION: %s.\n", debugstr_a(gl_version_str
));
2189 if (!gl_version_str
)
2192 ERR_(d3d_caps
)("Received a NULL GL_VERSION.\n");
2195 gl_version
= wined3d_parse_gl_version(gl_version_str
);
2198 * Initialize openGL extension related variables
2199 * with Default values
2201 memset(gl_info
->supported
, 0, sizeof(gl_info
->supported
));
2202 gl_info
->limits
.blends
= 1;
2203 gl_info
->limits
.buffers
= 1;
2204 gl_info
->limits
.textures
= 1;
2205 gl_info
->limits
.fragment_samplers
= 1;
2206 gl_info
->limits
.vertex_samplers
= 0;
2207 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
+ gl_info
->limits
.vertex_samplers
;
2208 gl_info
->limits
.sampler_stages
= 1;
2209 gl_info
->limits
.glsl_vs_float_constants
= 0;
2210 gl_info
->limits
.glsl_ps_float_constants
= 0;
2211 gl_info
->limits
.arb_vs_float_constants
= 0;
2212 gl_info
->limits
.arb_vs_native_constants
= 0;
2213 gl_info
->limits
.arb_vs_instructions
= 0;
2214 gl_info
->limits
.arb_vs_temps
= 0;
2215 gl_info
->limits
.arb_ps_float_constants
= 0;
2216 gl_info
->limits
.arb_ps_local_constants
= 0;
2217 gl_info
->limits
.arb_ps_instructions
= 0;
2218 gl_info
->limits
.arb_ps_temps
= 0;
2220 /* Retrieve opengl defaults */
2221 glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
2222 gl_info
->limits
.clipplanes
= min(WINED3DMAXUSERCLIPPLANES
, gl_max
);
2223 TRACE_(d3d_caps
)("ClipPlanes support - num Planes=%d\n", gl_max
);
2225 glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
2226 gl_info
->limits
.lights
= gl_max
;
2227 TRACE_(d3d_caps
)("Lights support - max lights=%d\n", gl_max
);
2229 glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &gl_max
);
2230 gl_info
->limits
.texture_size
= gl_max
;
2231 TRACE_(d3d_caps
)("Maximum texture size support - max texture size=%d\n", gl_max
);
2233 glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE
, gl_floatv
);
2234 gl_info
->limits
.pointsize_min
= gl_floatv
[0];
2235 gl_info
->limits
.pointsize_max
= gl_floatv
[1];
2236 TRACE_(d3d_caps
)("Maximum point size support - max point size=%f\n", gl_floatv
[1]);
2238 /* Parse the gl supported features, in theory enabling parts of our code appropriately. */
2239 GL_Extensions
= (const char *)glGetString(GL_EXTENSIONS
);
2243 ERR_(d3d_caps
)("Received a NULL GL_EXTENSIONS.\n");
2249 TRACE_(d3d_caps
)("GL_Extensions reported:\n");
2251 gl_info
->supported
[WINED3D_GL_EXT_NONE
] = TRUE
;
2253 while (*GL_Extensions
)
2257 while (isspace(*GL_Extensions
)) ++GL_Extensions
;
2258 start
= GL_Extensions
;
2259 while (!isspace(*GL_Extensions
) && *GL_Extensions
) ++GL_Extensions
;
2261 len
= GL_Extensions
- start
;
2264 TRACE_(d3d_caps
)("- %s\n", debugstr_an(start
, len
));
2266 for (i
= 0; i
< (sizeof(EXTENSION_MAP
) / sizeof(*EXTENSION_MAP
)); ++i
)
2268 if (len
== strlen(EXTENSION_MAP
[i
].extension_string
)
2269 && !memcmp(start
, EXTENSION_MAP
[i
].extension_string
, len
))
2271 TRACE_(d3d_caps
)(" FOUND: %s support.\n", EXTENSION_MAP
[i
].extension_string
);
2272 gl_info
->supported
[EXTENSION_MAP
[i
].extension
] = TRUE
;
2278 /* Now work out what GL support this card really has */
2279 load_gl_funcs( gl_info
, gl_version
);
2283 /* Now mark all the extensions supported which are included in the opengl core version. Do this *after*
2284 * loading the functions, otherwise the code above will load the extension entry points instead of the
2285 * core functions, which may not work. */
2286 for (i
= 0; i
< (sizeof(EXTENSION_MAP
) / sizeof(*EXTENSION_MAP
)); ++i
)
2288 if (!gl_info
->supported
[EXTENSION_MAP
[i
].extension
]
2289 && EXTENSION_MAP
[i
].version
<= gl_version
&& EXTENSION_MAP
[i
].version
)
2291 TRACE_(d3d_caps
)(" GL CORE: %s support.\n", EXTENSION_MAP
[i
].extension_string
);
2292 gl_info
->supported
[EXTENSION_MAP
[i
].extension
] = TRUE
;
2296 if (gl_version
>= MAKEDWORD_VERSION(2, 0)) gl_info
->supported
[WINED3D_GL_VERSION_2_0
] = TRUE
;
2298 if (gl_info
->supported
[APPLE_FENCE
])
2300 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
2301 * The apple extension interacts with some other apple exts. Disable the NV
2302 * extension if the apple one is support to prevent confusion in other parts
2304 gl_info
->supported
[NV_FENCE
] = FALSE
;
2306 if (gl_info
->supported
[APPLE_FLOAT_PIXELS
])
2308 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
2310 * The enums are the same:
2311 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881A
2312 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881B
2313 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
2314 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
2315 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140B
2317 if (!gl_info
->supported
[ARB_TEXTURE_FLOAT
])
2319 TRACE_(d3d_caps
)(" IMPLIED: GL_ARB_texture_float support(from GL_APPLE_float_pixels.\n");
2320 gl_info
->supported
[ARB_TEXTURE_FLOAT
] = TRUE
;
2322 if (!gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
2324 TRACE_(d3d_caps
)(" IMPLIED: GL_ARB_half_float_pixel support(from GL_APPLE_float_pixels.\n");
2325 gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
] = TRUE
;
2328 if (gl_info
->supported
[ARB_MAP_BUFFER_RANGE
])
2330 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
2331 * functionality. Prefer the ARB extension */
2332 gl_info
->supported
[APPLE_FLUSH_BUFFER_RANGE
] = FALSE
;
2334 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
2336 TRACE_(d3d_caps
)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
2337 gl_info
->supported
[NV_TEXGEN_REFLECTION
] = TRUE
;
2339 if (!gl_info
->supported
[ARB_DEPTH_CLAMP
] && gl_info
->supported
[NV_DEPTH_CLAMP
])
2341 TRACE_(d3d_caps
)(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
2342 gl_info
->supported
[ARB_DEPTH_CLAMP
] = TRUE
;
2344 if (!gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] && gl_info
->supported
[EXT_VERTEX_ARRAY_BGRA
])
2346 TRACE_(d3d_caps
)(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
2347 gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] = TRUE
;
2349 if (!gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] && gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
])
2351 TRACE_(d3d_caps
)(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
2352 gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] = TRUE
;
2354 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
2356 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2358 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
2359 * are supported. The nv extensions provide the same functionality as the
2360 * ATI one, and a bit more(signed pixelformats). */
2361 gl_info
->supported
[ATI_FRAGMENT_SHADER
] = FALSE
;
2365 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2367 glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV
, &gl_max
);
2368 gl_info
->limits
.general_combiners
= gl_max
;
2369 TRACE_(d3d_caps
)("Max general combiners: %d.\n", gl_max
);
2371 if (gl_info
->supported
[ARB_DRAW_BUFFERS
])
2373 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &gl_max
);
2374 gl_info
->limits
.buffers
= gl_max
;
2375 TRACE_(d3d_caps
)("Max draw buffers: %u.\n", gl_max
);
2377 if (gl_info
->supported
[ARB_MULTITEXTURE
])
2379 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
2380 gl_info
->limits
.textures
= min(MAX_TEXTURES
, gl_max
);
2381 TRACE_(d3d_caps
)("Max textures: %d.\n", gl_info
->limits
.textures
);
2383 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2386 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2387 gl_info
->limits
.fragment_samplers
= min(MAX_FRAGMENT_SAMPLERS
, tmp
);
2391 gl_info
->limits
.fragment_samplers
= max(gl_info
->limits
.fragment_samplers
, gl_max
);
2393 TRACE_(d3d_caps
)("Max fragment samplers: %d.\n", gl_info
->limits
.fragment_samplers
);
2395 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2398 glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2399 gl_info
->limits
.vertex_samplers
= tmp
;
2400 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2401 gl_info
->limits
.combined_samplers
= tmp
;
2403 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
2404 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
2405 * an issue because then the sampler setup only depends on the two shaders. If a pixel
2406 * shader is used with fixed function vertex processing we're fine too because fixed function
2407 * vertex processing doesn't use any samplers. If fixed function fragment processing is
2408 * used we have to make sure that all vertex sampler setups are valid together with all
2409 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
2410 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
2411 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
2412 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
2413 * a fixed function pipeline anymore.
2415 * So this is just a check to check that our assumption holds true. If not, write a warning
2416 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
2417 if (gl_info
->limits
.vertex_samplers
&& gl_info
->limits
.combined_samplers
< 12
2418 && MAX_TEXTURES
+ gl_info
->limits
.vertex_samplers
> gl_info
->limits
.combined_samplers
)
2420 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
2421 gl_info
->limits
.vertex_samplers
, gl_info
->limits
.combined_samplers
);
2422 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
2423 if (gl_info
->limits
.combined_samplers
> MAX_TEXTURES
)
2424 gl_info
->limits
.vertex_samplers
= gl_info
->limits
.combined_samplers
- MAX_TEXTURES
;
2426 gl_info
->limits
.vertex_samplers
= 0;
2431 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
;
2433 TRACE_(d3d_caps
)("Max vertex samplers: %u.\n", gl_info
->limits
.vertex_samplers
);
2434 TRACE_(d3d_caps
)("Max combined samplers: %u.\n", gl_info
->limits
.combined_samplers
);
2436 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
2438 glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB
, &gl_max
);
2439 gl_info
->limits
.blends
= gl_max
;
2440 TRACE_(d3d_caps
)("Max blends: %u.\n", gl_info
->limits
.blends
);
2442 if (gl_info
->supported
[EXT_TEXTURE3D
])
2444 glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT
, &gl_max
);
2445 gl_info
->limits
.texture3d_size
= gl_max
;
2446 TRACE_(d3d_caps
)("Max texture3D size: %d.\n", gl_info
->limits
.texture3d_size
);
2448 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
2450 glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, &gl_max
);
2451 gl_info
->limits
.anisotropy
= gl_max
;
2452 TRACE_(d3d_caps
)("Max anisotropy: %d.\n", gl_info
->limits
.anisotropy
);
2454 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2456 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2457 gl_info
->limits
.arb_ps_float_constants
= gl_max
;
2458 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_ps_float_constants
);
2459 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2460 gl_info
->limits
.arb_ps_native_constants
= gl_max
;
2461 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
2462 gl_info
->limits
.arb_ps_native_constants
);
2463 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2464 gl_info
->limits
.arb_ps_temps
= gl_max
;
2465 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_ps_temps
);
2466 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2467 gl_info
->limits
.arb_ps_instructions
= gl_max
;
2468 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2469 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB
, &gl_max
));
2470 gl_info
->limits
.arb_ps_local_constants
= gl_max
;
2471 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2473 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
])
2475 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2476 gl_info
->limits
.arb_vs_float_constants
= gl_max
;
2477 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_vs_float_constants
);
2478 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2479 gl_info
->limits
.arb_vs_native_constants
= gl_max
;
2480 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
2481 gl_info
->limits
.arb_vs_native_constants
);
2482 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2483 gl_info
->limits
.arb_vs_temps
= gl_max
;
2484 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_vs_temps
);
2485 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2486 gl_info
->limits
.arb_vs_instructions
= gl_max
;
2487 TRACE_(d3d_caps
)("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_vs_instructions
);
2489 if (test_arb_vs_offset_limit(gl_info
)) gl_info
->quirks
|= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT
;
2491 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2493 glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2494 gl_info
->limits
.glsl_vs_float_constants
= gl_max
/ 4;
2495 TRACE_(d3d_caps
)("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info
->limits
.glsl_vs_float_constants
);
2497 if (gl_info
->supported
[ARB_FRAGMENT_SHADER
])
2499 glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2500 gl_info
->limits
.glsl_ps_float_constants
= gl_max
/ 4;
2501 TRACE_(d3d_caps
)("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info
->limits
.glsl_ps_float_constants
);
2502 glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB
, &gl_max
);
2503 gl_info
->limits
.glsl_varyings
= gl_max
;
2504 TRACE_(d3d_caps
)("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max
, gl_max
/ 4);
2506 if (gl_info
->supported
[ARB_SHADING_LANGUAGE_100
])
2508 const char *str
= (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION_ARB
);
2509 unsigned int major
, minor
;
2511 TRACE_(d3d_caps
)("GLSL version string: %s.\n", debugstr_a(str
));
2513 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
2514 sscanf(str
, "%u.%u", &major
, &minor
);
2515 gl_info
->glsl_version
= MAKEDWORD_VERSION(major
, minor
);
2517 if (gl_info
->supported
[NV_LIGHT_MAX_EXPONENT
])
2519 glGetFloatv(GL_MAX_SHININESS_NV
, &gl_info
->limits
.shininess
);
2523 gl_info
->limits
.shininess
= 128.0f
;
2525 if (gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
2527 /* If we have full NP2 texture support, disable
2528 * GL_ARB_texture_rectangle because we will never use it.
2529 * This saves a few redundant glDisable calls. */
2530 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = FALSE
;
2532 if (gl_info
->supported
[ATI_FRAGMENT_SHADER
])
2534 /* Disable NV_register_combiners and fragment shader if this is supported.
2535 * generally the NV extensions are preferred over the ATI ones, and this
2536 * extension is disabled if register_combiners and texture_shader2 are both
2537 * supported. So we reach this place only if we have incomplete NV dxlevel 8
2538 * fragment processing support. */
2539 gl_info
->supported
[NV_REGISTER_COMBINERS
] = FALSE
;
2540 gl_info
->supported
[NV_REGISTER_COMBINERS2
] = FALSE
;
2541 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
2542 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
2544 if (gl_info
->supported
[NV_HALF_FLOAT
])
2546 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
2547 gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
] = TRUE
;
2549 if (gl_info
->supported
[ARB_POINT_SPRITE
])
2551 gl_info
->limits
.point_sprite_units
= gl_info
->limits
.textures
;
2555 gl_info
->limits
.point_sprite_units
= 0;
2557 checkGLcall("extension detection");
2561 adapter
->fragment_pipe
= select_fragment_implementation(adapter
);
2562 adapter
->shader_backend
= select_shader_backend(adapter
);
2563 adapter
->blitter
= select_blit_implementation(adapter
);
2565 adapter
->fragment_pipe
->get_caps(gl_info
, &fragment_caps
);
2566 gl_info
->limits
.texture_stages
= fragment_caps
.MaxTextureBlendStages
;
2567 TRACE_(d3d_caps
)("Max texture stages: %u.\n", gl_info
->limits
.texture_stages
);
2569 /* In some cases the number of texture stages can be larger than the number
2570 * of samplers. The GF4 for example can use only 2 samplers (no fragment
2571 * shaders), but 8 texture stages (register combiners). */
2572 gl_info
->limits
.sampler_stages
= max(gl_info
->limits
.fragment_samplers
, gl_info
->limits
.texture_stages
);
2574 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
2576 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->glIsRenderbuffer
;
2577 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->glBindRenderbuffer
;
2578 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->glDeleteRenderbuffers
;
2579 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->glGenRenderbuffers
;
2580 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->glRenderbufferStorage
;
2581 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->glRenderbufferStorageMultisample
;
2582 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->glGetRenderbufferParameteriv
;
2583 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->glIsFramebuffer
;
2584 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->glBindFramebuffer
;
2585 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->glDeleteFramebuffers
;
2586 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->glGenFramebuffers
;
2587 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->glCheckFramebufferStatus
;
2588 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->glFramebufferTexture1D
;
2589 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->glFramebufferTexture2D
;
2590 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->glFramebufferTexture3D
;
2591 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->glFramebufferRenderbuffer
;
2592 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
= gl_info
->glGetFramebufferAttachmentParameteriv
;
2593 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->glBlitFramebuffer
;
2594 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->glGenerateMipmap
;
2598 if (gl_info
->supported
[EXT_FRAMEBUFFER_OBJECT
])
2600 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->glIsRenderbufferEXT
;
2601 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->glBindRenderbufferEXT
;
2602 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->glDeleteRenderbuffersEXT
;
2603 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->glGenRenderbuffersEXT
;
2604 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->glRenderbufferStorageEXT
;
2605 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->glGetRenderbufferParameterivEXT
;
2606 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->glIsFramebufferEXT
;
2607 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->glBindFramebufferEXT
;
2608 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->glDeleteFramebuffersEXT
;
2609 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->glGenFramebuffersEXT
;
2610 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->glCheckFramebufferStatusEXT
;
2611 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->glFramebufferTexture1DEXT
;
2612 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->glFramebufferTexture2DEXT
;
2613 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->glFramebufferTexture3DEXT
;
2614 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->glFramebufferRenderbufferEXT
;
2615 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
= gl_info
->glGetFramebufferAttachmentParameterivEXT
;
2616 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->glGenerateMipmapEXT
;
2618 else if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
2620 WARN_(d3d_caps
)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
2621 wined3d_settings
.offscreen_rendering_mode
= ORM_BACKBUFFER
;
2623 if (gl_info
->supported
[EXT_FRAMEBUFFER_BLIT
])
2625 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->glBlitFramebufferEXT
;
2627 if (gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
2629 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->glRenderbufferStorageMultisampleEXT
;
2633 /* MRTs are currently only supported when FBOs are used. */
2634 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
2636 gl_info
->limits
.buffers
= 1;
2639 gl_vendor
= wined3d_guess_gl_vendor(gl_info
, gl_vendor_str
, gl_renderer_str
);
2640 card_vendor
= wined3d_guess_card_vendor(gl_vendor_str
, gl_renderer_str
);
2641 TRACE_(d3d_caps
)("found GL_VENDOR (%s)->(0x%04x/0x%04x)\n", debugstr_a(gl_vendor_str
), gl_vendor
, card_vendor
);
2643 device
= wined3d_guess_card(gl_info
, gl_renderer_str
, &gl_vendor
, &card_vendor
);
2644 TRACE_(d3d_caps
)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", card_vendor
, device
);
2646 gl_info
->wrap_lookup
[WINED3DTADDRESS_WRAP
- WINED3DTADDRESS_WRAP
] = GL_REPEAT
;
2647 gl_info
->wrap_lookup
[WINED3DTADDRESS_MIRROR
- WINED3DTADDRESS_WRAP
] =
2648 gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
] ? GL_MIRRORED_REPEAT_ARB
: GL_REPEAT
;
2649 gl_info
->wrap_lookup
[WINED3DTADDRESS_CLAMP
- WINED3DTADDRESS_WRAP
] = GL_CLAMP_TO_EDGE
;
2650 gl_info
->wrap_lookup
[WINED3DTADDRESS_BORDER
- WINED3DTADDRESS_WRAP
] =
2651 gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
] ? GL_CLAMP_TO_BORDER_ARB
: GL_REPEAT
;
2652 gl_info
->wrap_lookup
[WINED3DTADDRESS_MIRRORONCE
- WINED3DTADDRESS_WRAP
] =
2653 gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] ? GL_MIRROR_CLAMP_TO_EDGE_ATI
: GL_REPEAT
;
2655 /* Make sure there's an active HDC else the WGL extensions will fail */
2656 hdc
= pwglGetCurrentDC();
2658 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox */
2659 if(GL_EXTCALL(wglGetExtensionsStringARB
))
2660 WGL_Extensions
= GL_EXTCALL(wglGetExtensionsStringARB(hdc
));
2662 if (!WGL_Extensions
)
2664 ERR(" WGL_Extensions returns NULL\n");
2668 TRACE_(d3d_caps
)("WGL_Extensions reported:\n");
2669 while (*WGL_Extensions
)
2674 while (isspace(*WGL_Extensions
)) WGL_Extensions
++;
2675 Start
= WGL_Extensions
;
2676 while (!isspace(*WGL_Extensions
) && *WGL_Extensions
) ++WGL_Extensions
;
2678 len
= WGL_Extensions
- Start
;
2679 if (!len
|| len
>= sizeof(ThisExtn
))
2682 memcpy(ThisExtn
, Start
, len
);
2683 ThisExtn
[len
] = '\0';
2684 TRACE_(d3d_caps
)("- %s\n", debugstr_a(ThisExtn
));
2686 if (!strcmp(ThisExtn
, "WGL_ARB_pixel_format")) {
2687 gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
] = TRUE
;
2688 TRACE_(d3d_caps
)("FOUND: WGL_ARB_pixel_format support\n");
2690 if (!strcmp(ThisExtn
, "WGL_EXT_swap_control")) {
2691 gl_info
->supported
[WGL_EXT_SWAP_CONTROL
] = TRUE
;
2692 TRACE_(d3d_caps
)("FOUND: WGL_EXT_swap_control support\n");
2694 if (!strcmp(ThisExtn
, "WGL_WINE_pixel_format_passthrough")) {
2695 gl_info
->supported
[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH
] = TRUE
;
2696 TRACE_(d3d_caps
)("FOUND: WGL_WINE_pixel_format_passthrough support\n");
2702 fixup_extensions(gl_info
, gl_renderer_str
, gl_vendor
, card_vendor
, device
);
2703 init_driver_info(driver_info
, card_vendor
, device
);
2704 add_gl_compat_wrappers(gl_info
);
2709 UINT CDECL
wined3d_get_adapter_count(const struct wined3d
*wined3d
)
2711 TRACE_(d3d_caps
)("wined3d %p, reporting %u adapters.\n",
2712 wined3d
, wined3d
->adapter_count
);
2714 return wined3d
->adapter_count
;
2717 HRESULT CDECL
wined3d_register_software_device(struct wined3d
*wined3d
, void *init_function
)
2719 FIXME("wined3d %p, init_function %p stub!\n", wined3d
, init_function
);
2724 HMONITOR CDECL
wined3d_get_adapter_monitor(const struct wined3d
*wined3d
, UINT adapter_idx
)
2726 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u.\n", wined3d
, adapter_idx
);
2728 if (adapter_idx
>= wined3d
->adapter_count
)
2731 return MonitorFromPoint(wined3d
->adapters
[adapter_idx
].monitorPoint
, MONITOR_DEFAULTTOPRIMARY
);
2734 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
2735 of the same bpp but different resolutions */
2737 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2738 UINT CDECL
wined3d_get_adapter_mode_count(const struct wined3d
*wined3d
, UINT adapter_idx
,
2739 enum wined3d_format_id format_id
)
2741 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, format %s.\n", wined3d
, adapter_idx
, debug_d3dformat(format_id
));
2743 if (adapter_idx
>= wined3d
->adapter_count
)
2746 /* TODO: Store modes per adapter and read it from the adapter structure */
2749 const struct wined3d_format
*format
= wined3d_get_format(&wined3d
->adapters
[adapter_idx
].gl_info
, format_id
);
2750 UINT format_bits
= format
->byte_count
* CHAR_BIT
;
2755 memset(&mode
, 0, sizeof(mode
));
2756 mode
.dmSize
= sizeof(mode
);
2758 while (EnumDisplaySettingsExW(NULL
, j
, &mode
, 0))
2762 if (format_id
== WINED3DFMT_UNKNOWN
)
2764 /* This is for D3D8, do not enumerate P8 here */
2765 if (mode
.dmBitsPerPel
== 32 || mode
.dmBitsPerPel
== 16) ++i
;
2767 else if (mode
.dmBitsPerPel
== format_bits
)
2773 TRACE_(d3d_caps
)("Returning %u matching modes (out of %u total) for adapter %u.\n", i
, j
, adapter_idx
);
2779 FIXME_(d3d_caps
)("Adapter not primary display.\n");
2785 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2786 HRESULT CDECL
wined3d_enum_adapter_modes(const struct wined3d
*wined3d
, UINT adapter_idx
,
2787 enum wined3d_format_id format_id
, UINT mode_idx
, WINED3DDISPLAYMODE
*mode
)
2789 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, format %s, mode_idx %u, mode %p.\n",
2790 wined3d
, adapter_idx
, debug_d3dformat(format_id
), mode_idx
, mode
);
2792 /* Validate the parameters as much as possible */
2793 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
2794 || mode_idx
>= wined3d_get_adapter_mode_count(wined3d
, adapter_idx
, format_id
))
2796 return WINED3DERR_INVALIDCALL
;
2799 /* TODO: Store modes per adapter and read it from the adapter structure */
2802 const struct wined3d_format
*format
= wined3d_get_format(&wined3d
->adapters
[adapter_idx
].gl_info
, format_id
);
2803 UINT format_bits
= format
->byte_count
* CHAR_BIT
;
2809 ZeroMemory(&DevModeW
, sizeof(DevModeW
));
2810 DevModeW
.dmSize
= sizeof(DevModeW
);
2812 /* If we are filtering to a specific format (D3D9), then need to skip
2813 all unrelated modes, but if mode is irrelevant (D3D8), then we can
2814 just count through the ones with valid bit depths */
2815 while (i
<= mode_idx
&& EnumDisplaySettingsExW(NULL
, j
++, &DevModeW
, 0))
2817 if (format_id
== WINED3DFMT_UNKNOWN
)
2819 /* This is for D3D8, do not enumerate P8 here */
2820 if (DevModeW
.dmBitsPerPel
== 32 || DevModeW
.dmBitsPerPel
== 16) ++i
;
2822 else if (DevModeW
.dmBitsPerPel
== format_bits
)
2830 TRACE_(d3d_caps
)("No modes found for format (%x - %s)\n", format_id
, debug_d3dformat(format_id
));
2831 return WINED3DERR_INVALIDCALL
;
2835 /* Now get the display mode via the calculated index */
2836 if (EnumDisplaySettingsExW(NULL
, ModeIdx
, &DevModeW
, 0))
2838 mode
->Width
= DevModeW
.dmPelsWidth
;
2839 mode
->Height
= DevModeW
.dmPelsHeight
;
2840 mode
->RefreshRate
= DEFAULT_REFRESH_RATE
;
2841 if (DevModeW
.dmFields
& DM_DISPLAYFREQUENCY
)
2842 mode
->RefreshRate
= DevModeW
.dmDisplayFrequency
;
2844 if (format_id
== WINED3DFMT_UNKNOWN
)
2845 mode
->Format
= pixelformat_for_depth(DevModeW
.dmBitsPerPel
);
2847 mode
->Format
= format_id
;
2851 TRACE_(d3d_caps
)("Requested mode %u out of range.\n", mode_idx
);
2852 return WINED3DERR_INVALIDCALL
;
2855 TRACE_(d3d_caps
)("W %d H %d rr %d fmt (%x - %s) bpp %u\n",
2856 mode
->Width
, mode
->Height
, mode
->RefreshRate
, mode
->Format
,
2857 debug_d3dformat(mode
->Format
), DevModeW
.dmBitsPerPel
);
2861 FIXME_(d3d_caps
)("Adapter not primary display\n");
2867 HRESULT CDECL
wined3d_get_adapter_display_mode(const struct wined3d
*wined3d
, UINT adapter_idx
,
2868 WINED3DDISPLAYMODE
*mode
)
2870 TRACE("wined3d %p, adapter_idx %u, display_mode %p.\n", wined3d
, adapter_idx
, mode
);
2872 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
)
2873 return WINED3DERR_INVALIDCALL
;
2880 ZeroMemory(&DevModeW
, sizeof(DevModeW
));
2881 DevModeW
.dmSize
= sizeof(DevModeW
);
2883 EnumDisplaySettingsExW(NULL
, ENUM_CURRENT_SETTINGS
, &DevModeW
, 0);
2884 mode
->Width
= DevModeW
.dmPelsWidth
;
2885 mode
->Height
= DevModeW
.dmPelsHeight
;
2886 bpp
= DevModeW
.dmBitsPerPel
;
2887 mode
->RefreshRate
= DEFAULT_REFRESH_RATE
;
2888 if (DevModeW
.dmFields
&DM_DISPLAYFREQUENCY
)
2889 mode
->RefreshRate
= DevModeW
.dmDisplayFrequency
;
2890 mode
->Format
= pixelformat_for_depth(bpp
);
2894 FIXME_(d3d_caps
)("Adapter not primary display\n");
2897 TRACE_(d3d_caps
)("returning w:%d, h:%d, ref:%d, fmt:%s\n", mode
->Width
,
2898 mode
->Height
, mode
->RefreshRate
, debug_d3dformat(mode
->Format
));
2902 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
2903 and fields being inserted in the middle, a new structure is used in place */
2904 HRESULT CDECL
wined3d_get_adapter_identifier(const struct wined3d
*wined3d
,
2905 UINT adapter_idx
, DWORD flags
, WINED3DADAPTER_IDENTIFIER
*identifier
)
2907 const struct wined3d_adapter
*adapter
;
2910 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, flags %#x, indentifier %p.\n",
2911 wined3d
, adapter_idx
, flags
, identifier
);
2913 if (adapter_idx
>= wined3d
->adapter_count
)
2914 return WINED3DERR_INVALIDCALL
;
2916 adapter
= &wined3d
->adapters
[adapter_idx
];
2918 /* Return the information requested */
2919 TRACE_(d3d_caps
)("device/Vendor Name and Version detection using FillGLCaps\n");
2921 if (identifier
->driver_size
)
2923 const char *name
= adapter
->driver_info
.name
;
2924 len
= min(strlen(name
), identifier
->driver_size
- 1);
2925 memcpy(identifier
->driver
, name
, len
);
2926 identifier
->driver
[len
] = '\0';
2929 if (identifier
->description_size
)
2931 const char *description
= adapter
->driver_info
.description
;
2932 len
= min(strlen(description
), identifier
->description_size
- 1);
2933 memcpy(identifier
->description
, description
, len
);
2934 identifier
->description
[len
] = '\0';
2937 /* Note that d3d8 doesn't supply a device name. */
2938 if (identifier
->device_name_size
)
2940 static const char *device_name
= "\\\\.\\DISPLAY1"; /* FIXME: May depend on desktop? */
2942 len
= strlen(device_name
);
2943 if (len
>= identifier
->device_name_size
)
2945 ERR("Device name size too small.\n");
2946 return WINED3DERR_INVALIDCALL
;
2949 memcpy(identifier
->device_name
, device_name
, len
);
2950 identifier
->device_name
[len
] = '\0';
2953 identifier
->driver_version
.u
.HighPart
= adapter
->driver_info
.version_high
;
2954 identifier
->driver_version
.u
.LowPart
= adapter
->driver_info
.version_low
;
2955 identifier
->vendor_id
= adapter
->driver_info
.vendor
;
2956 identifier
->device_id
= adapter
->driver_info
.device
;
2957 identifier
->subsystem_id
= 0;
2958 identifier
->revision
= 0;
2959 memcpy(&identifier
->device_identifier
, &IID_D3DDEVICE_D3DUID
, sizeof(identifier
->device_identifier
));
2960 identifier
->whql_level
= (flags
& WINED3DENUM_NO_WHQL_LEVEL
) ? 0 : 1;
2961 memcpy(&identifier
->adapter_luid
, &adapter
->luid
, sizeof(identifier
->adapter_luid
));
2962 identifier
->video_memory
= adapter
->TextureRam
;
2967 static BOOL
wined3d_check_pixel_format_color(const struct wined3d_gl_info
*gl_info
,
2968 const struct wined3d_pixel_format
*cfg
, const struct wined3d_format
*format
)
2970 BYTE redSize
, greenSize
, blueSize
, alphaSize
, colorBits
;
2972 /* Float formats need FBOs. If FBOs are used this function isn't called */
2973 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
2975 if(cfg
->iPixelType
== WGL_TYPE_RGBA_ARB
) { /* Integer RGBA formats */
2976 if (!getColorBits(format
, &redSize
, &greenSize
, &blueSize
, &alphaSize
, &colorBits
))
2978 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
2982 if(cfg
->redSize
< redSize
)
2985 if(cfg
->greenSize
< greenSize
)
2988 if(cfg
->blueSize
< blueSize
)
2991 if(cfg
->alphaSize
< alphaSize
)
2997 /* Probably a RGBA_float or color index mode */
3001 static BOOL
wined3d_check_pixel_format_depth(const struct wined3d_gl_info
*gl_info
,
3002 const struct wined3d_pixel_format
*cfg
, const struct wined3d_format
*format
)
3004 BYTE depthSize
, stencilSize
;
3005 BOOL lockable
= FALSE
;
3007 if (!getDepthStencilBits(format
, &depthSize
, &stencilSize
))
3009 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
3013 /* Float formats need FBOs. If FBOs are used this function isn't called */
3014 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
3016 if ((format
->id
== WINED3DFMT_D16_LOCKABLE
) || (format
->id
== WINED3DFMT_D32_FLOAT
))
3019 /* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports.
3020 * We can safely report 'compatible' formats (e.g. D24 can be used for D16) as long as we aren't dealing with
3021 * a lockable format. This also helps D3D <= 7 as they expect D16 which isn't offered without this on Geforce8 cards. */
3022 if(!(cfg
->depthSize
== depthSize
|| (!lockable
&& cfg
->depthSize
> depthSize
)))
3025 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
3026 * allow more stencil bits than requested. */
3027 if(cfg
->stencilSize
< stencilSize
)
3033 HRESULT CDECL
wined3d_check_depth_stencil_match(const struct wined3d
*wined3d
,
3034 UINT adapter_idx
, WINED3DDEVTYPE device_type
, enum wined3d_format_id adapter_format_id
,
3035 enum wined3d_format_id render_target_format_id
, enum wined3d_format_id depth_stencil_format_id
)
3037 const struct wined3d_format
*rt_format
;
3038 const struct wined3d_format
*ds_format
;
3039 const struct wined3d_adapter
*adapter
;
3041 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s,\n"
3042 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
3043 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3044 debug_d3dformat(render_target_format_id
), debug_d3dformat(depth_stencil_format_id
));
3046 if (adapter_idx
>= wined3d
->adapter_count
)
3047 return WINED3DERR_INVALIDCALL
;
3049 adapter
= &wined3d
->adapters
[adapter_idx
];
3050 rt_format
= wined3d_get_format(&adapter
->gl_info
, render_target_format_id
);
3051 ds_format
= wined3d_get_format(&adapter
->gl_info
, depth_stencil_format_id
);
3052 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3054 if ((rt_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)
3055 && (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)))
3057 TRACE_(d3d_caps
)("Formats match.\n");
3063 const struct wined3d_pixel_format
*cfgs
;
3064 unsigned int cfg_count
;
3067 cfgs
= adapter
->cfgs
;
3068 cfg_count
= adapter
->nCfgs
;
3069 for (i
= 0; i
< cfg_count
; ++i
)
3071 if (wined3d_check_pixel_format_color(&adapter
->gl_info
, &cfgs
[i
], rt_format
)
3072 && wined3d_check_pixel_format_depth(&adapter
->gl_info
, &cfgs
[i
], ds_format
))
3074 TRACE_(d3d_caps
)("Formats match.\n");
3080 TRACE_(d3d_caps
)("Unsupported format pair: %s and %s.\n",
3081 debug_d3dformat(render_target_format_id
),
3082 debug_d3dformat(depth_stencil_format_id
));
3084 return WINED3DERR_NOTAVAILABLE
;
3087 HRESULT CDECL
wined3d_check_device_multisample_type(const struct wined3d
*wined3d
, UINT adapter_idx
,
3088 WINED3DDEVTYPE device_type
, enum wined3d_format_id surface_format_id
, BOOL windowed
,
3089 WINED3DMULTISAMPLE_TYPE multisample_type
, DWORD
*quality_levels
)
3091 const struct wined3d_adapter
*adapter
;
3092 const struct wined3d_format
*format
;
3094 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, surface_format %s,\n"
3095 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
3096 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(surface_format_id
),
3097 windowed
, multisample_type
, quality_levels
);
3099 if (adapter_idx
>= wined3d
->adapter_count
)
3100 return WINED3DERR_INVALIDCALL
;
3102 /* TODO: Handle windowed, add more quality levels. */
3104 if (WINED3DMULTISAMPLE_NONE
== multisample_type
)
3106 if (quality_levels
) *quality_levels
= 1;
3110 /* By default multisampling is disabled right now as it causes issues
3111 * on some Nvidia driver versions and it doesn't work well in combination
3113 if (!wined3d_settings
.allow_multisampling
)
3114 return WINED3DERR_NOTAVAILABLE
;
3116 adapter
= &wined3d
->adapters
[adapter_idx
];
3117 format
= wined3d_get_format(&adapter
->gl_info
, surface_format_id
);
3118 if (!format
) return WINED3DERR_INVALIDCALL
;
3120 if (format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
))
3122 const struct wined3d_pixel_format
*cfgs
;
3123 unsigned int i
, cfg_count
;
3125 cfgs
= adapter
->cfgs
;
3126 cfg_count
= adapter
->nCfgs
;
3127 for (i
= 0; i
< cfg_count
; ++i
)
3129 if(cfgs
[i
].numSamples
!= multisample_type
)
3132 if (!wined3d_check_pixel_format_depth(&adapter
->gl_info
, &cfgs
[i
], format
))
3135 TRACE("Found pixel format %u to support multisample_type %#x for format %s.\n",
3136 cfgs
[i
].iPixelFormat
, multisample_type
, debug_d3dformat(surface_format_id
));
3138 if (quality_levels
) *quality_levels
= 1;
3143 else if (format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)
3145 BYTE redSize
, greenSize
, blueSize
, alphaSize
, colorBits
;
3146 const struct wined3d_pixel_format
*cfgs
;
3147 unsigned int i
, cfg_count
;
3149 if (!getColorBits(format
, &redSize
, &greenSize
, &blueSize
, &alphaSize
, &colorBits
))
3151 ERR("Unable to get color bits for format %s, can't check multisampling capability.\n",
3152 debug_d3dformat(surface_format_id
));
3153 return WINED3DERR_NOTAVAILABLE
;
3156 cfgs
= adapter
->cfgs
;
3157 cfg_count
= adapter
->nCfgs
;
3158 for (i
= 0; i
< cfg_count
; ++i
)
3160 if(cfgs
[i
].numSamples
!= multisample_type
)
3162 if(cfgs
[i
].redSize
!= redSize
)
3164 if(cfgs
[i
].greenSize
!= greenSize
)
3166 if(cfgs
[i
].blueSize
!= blueSize
)
3168 /* Not all drivers report alpha-less formats since they use 32-bit
3169 * anyway, so accept alpha even if we didn't ask for it. */
3170 if(alphaSize
&& cfgs
[i
].alphaSize
!= alphaSize
)
3172 if (cfgs
[i
].colorSize
!= (format
->byte_count
<< 3))
3175 TRACE("Found pixel format %u to support multisample_type %#x for format %s.\n",
3176 cfgs
[i
].iPixelFormat
, multisample_type
, debug_d3dformat(surface_format_id
));
3178 if (quality_levels
) *quality_levels
= 1;
3183 return WINED3DERR_NOTAVAILABLE
;
3186 /* Check if we support bumpmapping for a format */
3187 static BOOL
CheckBumpMapCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3189 /* Ask the fixed function pipeline implementation if it can deal
3190 * with the conversion. If we've got a GL extension giving native
3191 * support this will be an identity conversion. */
3192 return (format
->flags
& WINED3DFMT_FLAG_BUMPMAP
)
3193 && adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
);
3196 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
3197 static BOOL
CheckDepthStencilCapability(const struct wined3d_adapter
*adapter
,
3198 const struct wined3d_format
*display_format
, const struct wined3d_format
*ds_format
)
3202 /* Only allow depth/stencil formats */
3203 if (!(ds_format
->depth_size
|| ds_format
->stencil_size
)) return FALSE
;
3205 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3207 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
3208 if (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)) return TRUE
;
3212 /* Walk through all WGL pixel formats to find a match */
3213 for (it
= 0; it
< adapter
->nCfgs
; ++it
)
3215 const struct wined3d_pixel_format
*cfg
= &adapter
->cfgs
[it
];
3216 if (wined3d_check_pixel_format_color(&adapter
->gl_info
, cfg
, display_format
)
3217 && wined3d_check_pixel_format_depth(&adapter
->gl_info
, cfg
, ds_format
))
3225 static BOOL
CheckFilterCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3227 /* The flags entry of a format contains the filtering capability */
3228 if (format
->flags
& WINED3DFMT_FLAG_FILTERING
) return TRUE
;
3233 /* Check the render target capabilities of a format */
3234 static BOOL
CheckRenderTargetCapability(const struct wined3d_adapter
*adapter
,
3235 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*check_format
)
3237 /* Filter out non-RT formats */
3238 if (!(check_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)) return FALSE
;
3239 if (wined3d_settings
.offscreen_rendering_mode
== ORM_BACKBUFFER
)
3241 BYTE AdapterRed
, AdapterGreen
, AdapterBlue
, AdapterAlpha
, AdapterTotalSize
;
3242 BYTE CheckRed
, CheckGreen
, CheckBlue
, CheckAlpha
, CheckTotalSize
;
3243 const struct wined3d_pixel_format
*cfgs
= adapter
->cfgs
;
3246 getColorBits(adapter_format
, &AdapterRed
, &AdapterGreen
, &AdapterBlue
, &AdapterAlpha
, &AdapterTotalSize
);
3247 getColorBits(check_format
, &CheckRed
, &CheckGreen
, &CheckBlue
, &CheckAlpha
, &CheckTotalSize
);
3249 /* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
3250 * The format must match in RGB, alpha is allowed to be different. (Only the backbuffer can have alpha) */
3251 if(!((AdapterRed
== CheckRed
) && (AdapterGreen
== CheckGreen
) && (AdapterBlue
== CheckBlue
))) {
3252 TRACE_(d3d_caps
)("[FAILED]\n");
3256 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
3257 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
3258 for (it
= 0; it
< adapter
->nCfgs
; ++it
)
3260 if (cfgs
[it
].windowDrawable
3261 && wined3d_check_pixel_format_color(&adapter
->gl_info
, &cfgs
[it
], check_format
))
3263 TRACE_(d3d_caps
)("Pixel format %d is compatible with format %s.\n",
3264 cfgs
[it
].iPixelFormat
, debug_d3dformat(check_format
->id
));
3269 else if(wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3271 /* For now return TRUE for FBOs until we have some proper checks.
3272 * Note that this function will only be called when the format is around for texturing. */
3278 static BOOL
CheckSrgbReadCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3280 return format
->flags
& WINED3DFMT_FLAG_SRGB_READ
;
3283 static BOOL
CheckSrgbWriteCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3285 /* Only offer SRGB writing on X8R8G8B8/A8R8G8B8 when we use ARB or GLSL shaders as we are
3286 * doing the color fixup in shaders.
3287 * Note Windows drivers (at least on the Geforce 8800) also offer this on R5G6B5. */
3288 if (format
->flags
& WINED3DFMT_FLAG_SRGB_WRITE
)
3290 int vs_selected_mode
;
3291 int ps_selected_mode
;
3292 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
3294 if((ps_selected_mode
== SHADER_ARB
) || (ps_selected_mode
== SHADER_GLSL
)) {
3295 TRACE_(d3d_caps
)("[OK]\n");
3300 TRACE_(d3d_caps
)("[FAILED] - sRGB writes not supported by format %s.\n", debug_d3dformat(format
->id
));
3304 /* Check if a format support blending in combination with pixel shaders */
3305 static BOOL
CheckPostPixelShaderBlendingCapability(const struct wined3d_adapter
*adapter
,
3306 const struct wined3d_format
*format
)
3308 /* The flags entry of a format contains the post pixel shader blending capability */
3309 if (format
->flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
) return TRUE
;
3314 static BOOL
CheckWrapAndMipCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3316 /* OpenGL supports mipmapping on all formats basically. Wrapping is unsupported,
3317 * but we have to report mipmapping so we cannot reject this flag. Tests show that
3318 * windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to show
3319 * that wrapping is supported. The lack of filtering will sort out the mipmapping
3320 * capability anyway.
3322 * For now lets report this on all formats, but in the future we may want to
3323 * restrict it to some should games need that
3328 /* Check if a texture format is supported on the given adapter */
3329 static BOOL
CheckTextureCapability(const struct wined3d_adapter
*adapter
, const struct wined3d_format
*format
)
3331 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3336 * supported: RGB(A) formats
3338 case WINED3DFMT_B8G8R8_UNORM
: /* Enable for dx7, blacklisted for 8 and 9 above */
3339 case WINED3DFMT_B8G8R8A8_UNORM
:
3340 case WINED3DFMT_B8G8R8X8_UNORM
:
3341 case WINED3DFMT_B5G6R5_UNORM
:
3342 case WINED3DFMT_B5G5R5X1_UNORM
:
3343 case WINED3DFMT_B5G5R5A1_UNORM
:
3344 case WINED3DFMT_B4G4R4A4_UNORM
:
3345 case WINED3DFMT_A8_UNORM
:
3346 case WINED3DFMT_B4G4R4X4_UNORM
:
3347 case WINED3DFMT_R8G8B8A8_UNORM
:
3348 case WINED3DFMT_R8G8B8X8_UNORM
:
3349 case WINED3DFMT_B10G10R10A2_UNORM
:
3350 case WINED3DFMT_R10G10B10A2_UNORM
:
3351 case WINED3DFMT_R16G16_UNORM
:
3352 TRACE_(d3d_caps
)("[OK]\n");
3355 case WINED3DFMT_B2G3R3_UNORM
:
3356 TRACE_(d3d_caps
)("[FAILED] - Not supported on Windows\n");
3360 * Not supported: Palettized
3361 * Only some Geforce/Voodoo3/G400 cards offer 8-bit textures in case of <=Direct3D7.
3362 * Since it is not widely available, don't offer it. Further no Windows driver offers
3363 * WINED3DFMT_P8_UINT_A8_NORM, so don't offer it either.
3365 case WINED3DFMT_P8_UINT
:
3366 case WINED3DFMT_P8_UINT_A8_UNORM
:
3370 * Supported: (Alpha)-Luminance
3372 case WINED3DFMT_L8_UNORM
:
3373 case WINED3DFMT_L8A8_UNORM
:
3374 case WINED3DFMT_L16_UNORM
:
3375 TRACE_(d3d_caps
)("[OK]\n");
3378 /* Not supported on Windows, thus disabled */
3379 case WINED3DFMT_L4A4_UNORM
:
3380 TRACE_(d3d_caps
)("[FAILED] - not supported on windows\n");
3384 * Supported: Depth/Stencil formats
3386 case WINED3DFMT_D16_LOCKABLE
:
3387 case WINED3DFMT_D16_UNORM
:
3388 case WINED3DFMT_S1_UINT_D15_UNORM
:
3389 case WINED3DFMT_X8D24_UNORM
:
3390 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
3391 case WINED3DFMT_D24_UNORM_S8_UINT
:
3392 case WINED3DFMT_S8_UINT_D24_FLOAT
:
3393 case WINED3DFMT_D32_UNORM
:
3394 case WINED3DFMT_D32_FLOAT
:
3397 case WINED3DFMT_INTZ
:
3398 if (gl_info
->supported
[EXT_PACKED_DEPTH_STENCIL
]
3399 || gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3404 * Not supported everywhere(depends on GL_ATI_envmap_bumpmap or
3405 * GL_NV_texture_shader). Emulated by shaders
3407 case WINED3DFMT_R8G8_SNORM
:
3408 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
3409 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
3410 case WINED3DFMT_R8G8B8A8_SNORM
:
3411 case WINED3DFMT_R16G16_SNORM
:
3412 /* Ask the shader backend if it can deal with the conversion. If
3413 * we've got a GL extension giving native support this will be an
3414 * identity conversion. */
3415 if (adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
))
3417 TRACE_(d3d_caps
)("[OK]\n");
3420 TRACE_(d3d_caps
)("[FAILED]\n");
3423 case WINED3DFMT_DXT1
:
3424 case WINED3DFMT_DXT2
:
3425 case WINED3DFMT_DXT3
:
3426 case WINED3DFMT_DXT4
:
3427 case WINED3DFMT_DXT5
:
3428 if (gl_info
->supported
[EXT_TEXTURE_COMPRESSION_S3TC
])
3430 TRACE_(d3d_caps
)("[OK]\n");
3433 TRACE_(d3d_caps
)("[FAILED]\n");
3438 * Odd formats - not supported
3440 case WINED3DFMT_VERTEXDATA
:
3441 case WINED3DFMT_R16_UINT
:
3442 case WINED3DFMT_R32_UINT
:
3443 case WINED3DFMT_R16G16B16A16_SNORM
:
3444 case WINED3DFMT_R10G10B10_SNORM_A2_UNORM
:
3445 case WINED3DFMT_R10G11B11_SNORM
:
3446 case WINED3DFMT_R16
:
3447 case WINED3DFMT_AL16
:
3448 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3452 * WINED3DFMT_R8G8_SNORM_Cx: Not supported right now
3454 case WINED3DFMT_R8G8_SNORM_Cx
:
3455 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3459 case WINED3DFMT_UYVY
:
3460 case WINED3DFMT_YUY2
:
3461 if (gl_info
->supported
[APPLE_YCBCR_422
])
3463 TRACE_(d3d_caps
)("[OK]\n");
3466 TRACE_(d3d_caps
)("[FAILED]\n");
3468 case WINED3DFMT_YV12
:
3469 TRACE_(d3d_caps
)("[FAILED]\n");
3473 case WINED3DFMT_R16G16B16A16_UNORM
:
3474 case WINED3DFMT_B2G3R3A8_UNORM
:
3475 TRACE_(d3d_caps
)("[FAILED]\n"); /* Enable when implemented */
3478 /* Floating point formats */
3479 case WINED3DFMT_R16_FLOAT
:
3480 case WINED3DFMT_R16G16_FLOAT
:
3481 case WINED3DFMT_R16G16B16A16_FLOAT
:
3482 if (gl_info
->supported
[ARB_TEXTURE_FLOAT
] && gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
3484 TRACE_(d3d_caps
)("[OK]\n");
3487 TRACE_(d3d_caps
)("[FAILED]\n");
3490 case WINED3DFMT_R32_FLOAT
:
3491 case WINED3DFMT_R32G32_FLOAT
:
3492 case WINED3DFMT_R32G32B32A32_FLOAT
:
3493 if (gl_info
->supported
[ARB_TEXTURE_FLOAT
])
3495 TRACE_(d3d_caps
)("[OK]\n");
3498 TRACE_(d3d_caps
)("[FAILED]\n");
3501 /* ATI instancing hack: Although ATI cards do not support Shader Model 3.0, they support
3502 * instancing. To query if the card supports instancing CheckDeviceFormat with the special format
3503 * MAKEFOURCC('I','N','S','T') is used. Should a (broken) app check for this provide a proper return value.
3504 * We can do instancing with all shader versions, but we need vertex shaders.
3506 * Additionally applications have to set the D3DRS_POINTSIZE render state to MAKEFOURCC('I','N','S','T') once
3507 * to enable instancing. WineD3D doesn't need that and just ignores it.
3509 * With Shader Model 3.0 capable cards Instancing 'just works' in Windows.
3511 case WINED3DFMT_INST
:
3512 TRACE("ATI Instancing check hack\n");
3513 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
] || gl_info
->supported
[ARB_VERTEX_SHADER
])
3515 TRACE_(d3d_caps
)("[OK]\n");
3518 TRACE_(d3d_caps
)("[FAILED]\n");
3521 /* Some weird FOURCC formats */
3522 case WINED3DFMT_R8G8_B8G8
:
3523 case WINED3DFMT_G8R8_G8B8
:
3524 case WINED3DFMT_MULTI2_ARGB8
:
3525 TRACE_(d3d_caps
)("[FAILED]\n");
3528 /* Vendor specific formats */
3529 case WINED3DFMT_ATI2N
:
3530 if (gl_info
->supported
[ATI_TEXTURE_COMPRESSION_3DC
]
3531 || gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
])
3533 if (adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
)
3534 && adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
))
3536 TRACE_(d3d_caps
)("[OK]\n");
3540 TRACE_(d3d_caps
)("[OK]\n");
3543 TRACE_(d3d_caps
)("[FAILED]\n");
3546 /* Depth bound test. To query if the card supports it CheckDeviceFormat with the special
3547 * format MAKEFOURCC('N','V','D','B') is used.
3548 * It is enabled by setting D3DRS_ADAPTIVETESS_X render state to MAKEFOURCC('N','V','D','B') and
3549 * then controlled by setting D3DRS_ADAPTIVETESS_Z (zMin) and D3DRS_ADAPTIVETESS_W (zMax)
3552 case WINED3DFMT_NVDB
:
3553 if (gl_info
->supported
[EXT_DEPTH_BOUNDS_TEST
])
3555 TRACE_(d3d_caps
)("[OK]\n");
3558 TRACE_(d3d_caps
)("[FAILED]\n");
3561 case WINED3DFMT_NVHU
:
3562 case WINED3DFMT_NVHS
:
3563 /* These formats seem to be similar to the HILO formats in GL_NV_texture_shader. NVHU
3564 * is said to be GL_UNSIGNED_HILO16, NVHS GL_SIGNED_HILO16. Rumours say that d3d computes
3565 * a 3rd channel similarly to D3DFMT_CxV8U8(So NVHS could be called D3DFMT_CxV16U16).
3566 * ATI refused to support formats which can easilly be emulated with pixel shaders, so
3567 * Applications have to deal with not having NVHS and NVHU.
3569 TRACE_(d3d_caps
)("[FAILED]\n");
3572 case WINED3DFMT_NULL
:
3573 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3577 case WINED3DFMT_UNKNOWN
:
3581 ERR("Unhandled format %s.\n", debug_d3dformat(format
->id
));
3587 static BOOL
CheckSurfaceCapability(const struct wined3d_adapter
*adapter
,
3588 const struct wined3d_format
*adapter_format
,
3589 const struct wined3d_format
*check_format
,
3590 WINED3DSURFTYPE SurfaceType
)
3592 if (SurfaceType
== SURFACE_GDI
)
3594 switch (check_format
->id
)
3596 case WINED3DFMT_B8G8R8_UNORM
:
3597 case WINED3DFMT_B8G8R8A8_UNORM
:
3598 case WINED3DFMT_B8G8R8X8_UNORM
:
3599 case WINED3DFMT_B5G6R5_UNORM
:
3600 case WINED3DFMT_B5G5R5X1_UNORM
:
3601 case WINED3DFMT_B5G5R5A1_UNORM
:
3602 case WINED3DFMT_B4G4R4A4_UNORM
:
3603 case WINED3DFMT_B2G3R3_UNORM
:
3604 case WINED3DFMT_A8_UNORM
:
3605 case WINED3DFMT_B2G3R3A8_UNORM
:
3606 case WINED3DFMT_B4G4R4X4_UNORM
:
3607 case WINED3DFMT_R10G10B10A2_UNORM
:
3608 case WINED3DFMT_R8G8B8A8_UNORM
:
3609 case WINED3DFMT_R8G8B8X8_UNORM
:
3610 case WINED3DFMT_R16G16_UNORM
:
3611 case WINED3DFMT_B10G10R10A2_UNORM
:
3612 case WINED3DFMT_R16G16B16A16_UNORM
:
3613 case WINED3DFMT_P8_UINT
:
3614 TRACE_(d3d_caps
)("[OK]\n");
3617 TRACE_(d3d_caps
)("[FAILED] - not available on GDI surfaces\n");
3622 /* All format that are supported for textures are supported for surfaces as well */
3623 if (CheckTextureCapability(adapter
, check_format
)) return TRUE
;
3624 /* All depth stencil formats are supported on surfaces */
3625 if (CheckDepthStencilCapability(adapter
, adapter_format
, check_format
)) return TRUE
;
3627 /* If opengl can't process the format natively, the blitter may be able to convert it */
3628 if (adapter
->blitter
->blit_supported(&adapter
->gl_info
, WINED3D_BLIT_OP_COLOR_BLIT
,
3629 NULL
, WINED3DPOOL_DEFAULT
, 0, check_format
,
3630 NULL
, WINED3DPOOL_DEFAULT
, 0, adapter_format
))
3632 TRACE_(d3d_caps
)("[OK]\n");
3636 /* Reject other formats */
3637 TRACE_(d3d_caps
)("[FAILED]\n");
3641 static BOOL
CheckVertexTextureCapability(const struct wined3d_adapter
*adapter
,
3642 const struct wined3d_format
*format
)
3644 return adapter
->gl_info
.limits
.vertex_samplers
&& (format
->flags
& WINED3DFMT_FLAG_VTF
);
3647 HRESULT CDECL
wined3d_check_device_format(const struct wined3d
*wined3d
, UINT adapter_idx
,
3648 WINED3DDEVTYPE device_type
, enum wined3d_format_id adapter_format_id
, DWORD usage
,
3649 WINED3DRESOURCETYPE resource_type
, enum wined3d_format_id check_format_id
, WINED3DSURFTYPE surface_type
)
3651 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
3652 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3653 const struct wined3d_format
*adapter_format
= wined3d_get_format(gl_info
, adapter_format_id
);
3654 const struct wined3d_format
*format
= wined3d_get_format(gl_info
, check_format_id
);
3655 DWORD usage_caps
= 0;
3657 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s,\n"
3658 "resource_type %s, check_format %s, surface_type %#x.\n",
3659 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3660 debug_d3dusage(usage
), debug_d3dusagequery(usage
), debug_d3dresourcetype(resource_type
),
3661 debug_d3dformat(check_format_id
), surface_type
);
3663 if (adapter_idx
>= wined3d
->adapter_count
)
3664 return WINED3DERR_INVALIDCALL
;
3666 switch (resource_type
)
3668 case WINED3DRTYPE_CUBETEXTURE
:
3669 /* Cubetexture allows:
3670 * - WINED3DUSAGE_AUTOGENMIPMAP
3671 * - WINED3DUSAGE_DEPTHSTENCIL
3672 * - WINED3DUSAGE_DYNAMIC
3673 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3674 * - WINED3DUSAGE_RENDERTARGET
3675 * - WINED3DUSAGE_SOFTWAREPROCESSING
3676 * - WINED3DUSAGE_QUERY_WRAPANDMIP
3678 if (surface_type
!= SURFACE_OPENGL
)
3680 TRACE_(d3d_caps
)("[FAILED]\n");
3681 return WINED3DERR_NOTAVAILABLE
;
3684 if (!gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3686 TRACE_(d3d_caps
)("[FAILED] - No cube texture support\n");
3687 return WINED3DERR_NOTAVAILABLE
;
3690 if (!CheckTextureCapability(adapter
, format
))
3692 TRACE_(d3d_caps
)("[FAILED] - Cube texture format not supported\n");
3693 return WINED3DERR_NOTAVAILABLE
;
3696 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
3698 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
3699 /* When autogenmipmap isn't around continue and return
3700 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
3701 TRACE_(d3d_caps
)("[FAILED] - No autogenmipmap support, but continuing\n");
3703 usage_caps
|= WINED3DUSAGE_AUTOGENMIPMAP
;
3706 /* Always report dynamic locking. */
3707 if (usage
& WINED3DUSAGE_DYNAMIC
)
3708 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
3710 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3712 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3714 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3715 return WINED3DERR_NOTAVAILABLE
;
3717 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3720 /* Always report software processing. */
3721 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
3722 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
3724 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
3726 if (!CheckFilterCapability(adapter
, format
))
3728 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
3729 return WINED3DERR_NOTAVAILABLE
;
3731 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
3734 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3736 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3738 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3739 return WINED3DERR_NOTAVAILABLE
;
3741 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3744 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
3746 if (!CheckSrgbReadCapability(adapter
, format
))
3748 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
3749 return WINED3DERR_NOTAVAILABLE
;
3751 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
3754 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
3756 if (!CheckSrgbWriteCapability(adapter
, format
))
3758 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
3759 return WINED3DERR_NOTAVAILABLE
;
3761 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
3764 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
3766 if (!CheckVertexTextureCapability(adapter
, format
))
3768 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
3769 return WINED3DERR_NOTAVAILABLE
;
3771 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
3774 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
3776 if (!CheckWrapAndMipCapability(adapter
, format
))
3778 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
3779 return WINED3DERR_NOTAVAILABLE
;
3781 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
3785 case WINED3DRTYPE_SURFACE
:
3787 * - WINED3DUSAGE_DEPTHSTENCIL
3788 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3789 * - WINED3DUSAGE_RENDERTARGET
3791 if (!CheckSurfaceCapability(adapter
, adapter_format
, format
, surface_type
))
3793 TRACE_(d3d_caps
)("[FAILED] - Not supported for plain surfaces\n");
3794 return WINED3DERR_NOTAVAILABLE
;
3797 if (usage
& WINED3DUSAGE_DEPTHSTENCIL
)
3799 if (!CheckDepthStencilCapability(adapter
, adapter_format
, format
))
3801 TRACE_(d3d_caps
)("[FAILED] - No depthstencil support\n");
3802 return WINED3DERR_NOTAVAILABLE
;
3804 usage_caps
|= WINED3DUSAGE_DEPTHSTENCIL
;
3807 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3809 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3811 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3812 return WINED3DERR_NOTAVAILABLE
;
3814 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3817 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3819 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3821 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3822 return WINED3DERR_NOTAVAILABLE
;
3824 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3828 case WINED3DRTYPE_TEXTURE
:
3830 * - WINED3DUSAGE_AUTOGENMIPMAP
3831 * - WINED3DUSAGE_DEPTHSTENCIL
3832 * - WINED3DUSAGE_DMAP
3833 * - WINED3DUSAGE_DYNAMIC
3834 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3835 * - WINED3DUSAGE_RENDERTARGET
3836 * - WINED3DUSAGE_SOFTWAREPROCESSING
3837 * - WINED3DUSAGE_TEXTAPI (d3d9ex)
3838 * - WINED3DUSAGE_QUERY_WRAPANDMIP
3840 if (surface_type
!= SURFACE_OPENGL
)
3842 TRACE_(d3d_caps
)("[FAILED]\n");
3843 return WINED3DERR_NOTAVAILABLE
;
3846 if (!CheckTextureCapability(adapter
, format
))
3848 TRACE_(d3d_caps
)("[FAILED] - Texture format not supported\n");
3849 return WINED3DERR_NOTAVAILABLE
;
3852 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
3854 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
3855 /* When autogenmipmap isn't around continue and return
3856 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
3857 TRACE_(d3d_caps
)("[FAILED] - No autogenmipmap support, but continuing\n");
3859 usage_caps
|= WINED3DUSAGE_AUTOGENMIPMAP
;
3862 /* Always report dynamic locking. */
3863 if (usage
& WINED3DUSAGE_DYNAMIC
)
3864 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
3866 if (usage
& WINED3DUSAGE_RENDERTARGET
)
3868 if (!CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3870 TRACE_(d3d_caps
)("[FAILED] - No rendertarget support\n");
3871 return WINED3DERR_NOTAVAILABLE
;
3873 usage_caps
|= WINED3DUSAGE_RENDERTARGET
;
3876 /* Always report software processing. */
3877 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
3878 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
3880 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
3882 if (!CheckFilterCapability(adapter
, format
))
3884 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
3885 return WINED3DERR_NOTAVAILABLE
;
3887 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
3890 if (usage
& WINED3DUSAGE_QUERY_LEGACYBUMPMAP
)
3892 if (!CheckBumpMapCapability(adapter
, format
))
3894 TRACE_(d3d_caps
)("[FAILED] - No legacy bumpmap support\n");
3895 return WINED3DERR_NOTAVAILABLE
;
3897 usage_caps
|= WINED3DUSAGE_QUERY_LEGACYBUMPMAP
;
3900 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3902 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
3904 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
3905 return WINED3DERR_NOTAVAILABLE
;
3907 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3910 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
3912 if (!CheckSrgbReadCapability(adapter
, format
))
3914 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
3915 return WINED3DERR_NOTAVAILABLE
;
3917 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
3920 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
3922 if (!CheckSrgbWriteCapability(adapter
, format
))
3924 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
3925 return WINED3DERR_NOTAVAILABLE
;
3927 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
3930 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
3932 if (!CheckVertexTextureCapability(adapter
, format
))
3934 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
3935 return WINED3DERR_NOTAVAILABLE
;
3937 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
3940 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
3942 if (!CheckWrapAndMipCapability(adapter
, format
))
3944 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
3945 return WINED3DERR_NOTAVAILABLE
;
3947 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
3950 if (usage
& WINED3DUSAGE_DEPTHSTENCIL
)
3952 if (!CheckDepthStencilCapability(adapter
, adapter_format
, format
))
3954 TRACE_(d3d_caps
)("[FAILED] - No depth stencil support\n");
3955 return WINED3DERR_NOTAVAILABLE
;
3957 if ((format
->flags
& WINED3DFMT_FLAG_SHADOW
) && !gl_info
->supported
[ARB_SHADOW
])
3959 TRACE_(d3d_caps
)("[FAILED] - No shadow sampler support.\n");
3960 return WINED3DERR_NOTAVAILABLE
;
3962 usage_caps
|= WINED3DUSAGE_DEPTHSTENCIL
;
3966 case WINED3DRTYPE_VOLUMETEXTURE
:
3967 case WINED3DRTYPE_VOLUME
:
3968 /* Volume is to VolumeTexture what Surface is to Texture, but its
3969 * usage caps are not documented. Most driver seem to offer
3970 * (nearly) the same on Volume and VolumeTexture, so do that too.
3972 * Volumetexture allows:
3973 * - D3DUSAGE_DYNAMIC
3974 * - D3DUSAGE_NONSECURE (d3d9ex)
3975 * - D3DUSAGE_SOFTWAREPROCESSING
3976 * - D3DUSAGE_QUERY_WRAPANDMIP
3978 if (surface_type
!= SURFACE_OPENGL
)
3980 TRACE_(d3d_caps
)("[FAILED]\n");
3981 return WINED3DERR_NOTAVAILABLE
;
3984 if (!gl_info
->supported
[EXT_TEXTURE3D
])
3986 TRACE_(d3d_caps
)("[FAILED] - No volume texture support\n");
3987 return WINED3DERR_NOTAVAILABLE
;
3990 if (!CheckTextureCapability(adapter
, format
))
3992 TRACE_(d3d_caps
)("[FAILED] - Format not supported\n");
3993 return WINED3DERR_NOTAVAILABLE
;
3996 /* Filter formats that need conversion; For one part, this
3997 * conversion is unimplemented, and volume textures are huge, so
3998 * it would be a big performance hit. Unless we hit an application
3999 * needing one of those formats, don't advertize them to avoid
4000 * leading applications into temptation. The windows drivers don't
4001 * support most of those formats on volumes anyway, except for
4002 * WINED3DFMT_R32_FLOAT. */
4003 switch (check_format_id
)
4005 case WINED3DFMT_P8_UINT
:
4006 case WINED3DFMT_L4A4_UNORM
:
4007 case WINED3DFMT_R32_FLOAT
:
4008 case WINED3DFMT_R16_FLOAT
:
4009 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
4010 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
4011 case WINED3DFMT_R16G16_UNORM
:
4012 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
4013 return WINED3DERR_NOTAVAILABLE
;
4015 case WINED3DFMT_R8G8B8A8_SNORM
:
4016 case WINED3DFMT_R16G16_SNORM
:
4017 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
4019 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
4020 return WINED3DERR_NOTAVAILABLE
;
4024 case WINED3DFMT_R8G8_SNORM
:
4025 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
4027 TRACE_(d3d_caps
)("[FAILED] - No converted formats on volumes\n");
4028 return WINED3DERR_NOTAVAILABLE
;
4032 case WINED3DFMT_DXT1
:
4033 case WINED3DFMT_DXT2
:
4034 case WINED3DFMT_DXT3
:
4035 case WINED3DFMT_DXT4
:
4036 case WINED3DFMT_DXT5
:
4037 /* The GL_EXT_texture_compression_s3tc spec requires that
4038 * loading an s3tc compressed texture results in an error.
4039 * While the D3D refrast does support s3tc volumes, at
4040 * least the nvidia windows driver does not, so we're free
4041 * not to support this format. */
4042 TRACE_(d3d_caps
)("[FAILED] - DXTn does not support 3D textures\n");
4043 return WINED3DERR_NOTAVAILABLE
;
4046 /* Do nothing, continue with checking the format below */
4050 /* Always report dynamic locking. */
4051 if (usage
& WINED3DUSAGE_DYNAMIC
)
4052 usage_caps
|= WINED3DUSAGE_DYNAMIC
;
4054 /* Always report software processing. */
4055 if (usage
& WINED3DUSAGE_SOFTWAREPROCESSING
)
4056 usage_caps
|= WINED3DUSAGE_SOFTWAREPROCESSING
;
4058 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
4060 if (!CheckFilterCapability(adapter
, format
))
4062 TRACE_(d3d_caps
)("[FAILED] - No query filter support\n");
4063 return WINED3DERR_NOTAVAILABLE
;
4065 usage_caps
|= WINED3DUSAGE_QUERY_FILTER
;
4068 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
4070 if (!CheckPostPixelShaderBlendingCapability(adapter
, format
))
4072 TRACE_(d3d_caps
)("[FAILED] - No query post pixelshader blending support\n");
4073 return WINED3DERR_NOTAVAILABLE
;
4075 usage_caps
|= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
4078 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
4080 if (!CheckSrgbReadCapability(adapter
, format
))
4082 TRACE_(d3d_caps
)("[FAILED] - No query srgbread support\n");
4083 return WINED3DERR_NOTAVAILABLE
;
4085 usage_caps
|= WINED3DUSAGE_QUERY_SRGBREAD
;
4088 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
4090 if (!CheckSrgbWriteCapability(adapter
, format
))
4092 TRACE_(d3d_caps
)("[FAILED] - No query srgbwrite support\n");
4093 return WINED3DERR_NOTAVAILABLE
;
4095 usage_caps
|= WINED3DUSAGE_QUERY_SRGBWRITE
;
4098 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
4100 if (!CheckVertexTextureCapability(adapter
, format
))
4102 TRACE_(d3d_caps
)("[FAILED] - No query vertextexture support\n");
4103 return WINED3DERR_NOTAVAILABLE
;
4105 usage_caps
|= WINED3DUSAGE_QUERY_VERTEXTEXTURE
;
4108 if (usage
& WINED3DUSAGE_QUERY_WRAPANDMIP
)
4110 if (!CheckWrapAndMipCapability(adapter
, format
))
4112 TRACE_(d3d_caps
)("[FAILED] - No wrapping and mipmapping support\n");
4113 return WINED3DERR_NOTAVAILABLE
;
4115 usage_caps
|= WINED3DUSAGE_QUERY_WRAPANDMIP
;
4120 FIXME_(d3d_caps
)("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type
));
4121 return WINED3DERR_NOTAVAILABLE
;
4124 /* When the usage_caps exactly matches usage return WINED3D_OK except for
4125 * the situation in which WINED3DUSAGE_AUTOGENMIPMAP isn't around, then
4126 * WINED3DOK_NOAUTOGEN is returned if all the other usage flags match. */
4127 if (usage_caps
== usage
)
4129 if (usage_caps
== (usage
& ~WINED3DUSAGE_AUTOGENMIPMAP
))
4130 return WINED3DOK_NOAUTOGEN
;
4132 TRACE_(d3d_caps
)("[FAILED] - Usage %#x requested for format %s and resource_type %s but only %#x is available.\n",
4133 usage
, debug_d3dformat(check_format_id
), debug_d3dresourcetype(resource_type
), usage_caps
);
4135 return WINED3DERR_NOTAVAILABLE
;
4138 HRESULT CDECL
wined3d_check_device_format_conversion(const struct wined3d
*wined3d
, UINT adapter_idx
,
4139 WINED3DDEVTYPE device_type
, enum wined3d_format_id src_format
, enum wined3d_format_id dst_format
)
4141 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
4142 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(src_format
),
4143 debug_d3dformat(dst_format
));
4148 HRESULT CDECL
wined3d_check_device_type(const struct wined3d
*wined3d
, UINT adapter_idx
, WINED3DDEVTYPE device_type
,
4149 enum wined3d_format_id display_format
, enum wined3d_format_id backbuffer_format
, BOOL windowed
)
4154 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
4155 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(display_format
),
4156 debug_d3dformat(backbuffer_format
), windowed
);
4158 if (adapter_idx
>= wined3d
->adapter_count
)
4159 return WINED3DERR_INVALIDCALL
;
4161 /* The task of this function is to check whether a certain display / backbuffer format
4162 * combination is available on the given adapter. In fullscreen mode microsoft specified
4163 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
4164 * and display format should match exactly.
4165 * In windowed mode format conversion can occur and this depends on the driver. When format
4166 * conversion is done, this function should nevertheless fail and applications need to use
4167 * CheckDeviceFormatConversion.
4168 * At the moment we assume that fullscreen and windowed have the same capabilities. */
4170 /* There are only 4 display formats. */
4171 if (!(display_format
== WINED3DFMT_B5G6R5_UNORM
4172 || display_format
== WINED3DFMT_B5G5R5X1_UNORM
4173 || display_format
== WINED3DFMT_B8G8R8X8_UNORM
4174 || display_format
== WINED3DFMT_B10G10R10A2_UNORM
))
4176 TRACE_(d3d_caps
)("Format %s is not supported as display format.\n", debug_d3dformat(display_format
));
4177 return WINED3DERR_NOTAVAILABLE
;
4180 /* If the requested display format is not available, don't continue. */
4181 mode_count
= wined3d_get_adapter_mode_count(wined3d
, adapter_idx
, display_format
);
4184 TRACE_(d3d_caps
)("No available modes for display format %s.\n", debug_d3dformat(display_format
));
4185 return WINED3DERR_NOTAVAILABLE
;
4188 /* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbuffer format,
4189 * it means 'reuse' the display format for the backbuffer. */
4190 if (!windowed
&& backbuffer_format
== WINED3DFMT_UNKNOWN
)
4192 TRACE_(d3d_caps
)("backbuffer_format WINED3FMT_UNKNOWN only available in windowed mode.\n");
4193 return WINED3DERR_NOTAVAILABLE
;
4196 /* In FULLSCREEN mode WINED3DFMT_B5G6R5_UNORM can only be mixed with
4197 * backbuffer format WINED3DFMT_B5G6R5_UNORM. */
4198 if (display_format
== WINED3DFMT_B5G6R5_UNORM
&& backbuffer_format
!= WINED3DFMT_B5G6R5_UNORM
)
4200 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4201 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4202 return WINED3DERR_NOTAVAILABLE
;
4205 /* In FULLSCREEN mode WINED3DFMT_B5G5R5X1_UNORM can only be mixed with
4206 * backbuffer formats WINED3DFMT_B5G5R5X1_UNORM and
4207 * WINED3DFMT_B5G5R5A1_UNORM. */
4208 if (display_format
== WINED3DFMT_B5G5R5X1_UNORM
4209 && !(backbuffer_format
== WINED3DFMT_B5G5R5X1_UNORM
|| backbuffer_format
== WINED3DFMT_B5G5R5A1_UNORM
))
4211 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4212 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4213 return WINED3DERR_NOTAVAILABLE
;
4216 /* In FULLSCREEN mode WINED3DFMT_B8G8R8X8_UNORM can only be mixed with
4217 * backbuffer formats WINED3DFMT_B8G8R8X8_UNORM and
4218 * WINED3DFMT_B8G8R8A8_UNORM. */
4219 if (display_format
== WINED3DFMT_B8G8R8X8_UNORM
4220 && !(backbuffer_format
== WINED3DFMT_B8G8R8X8_UNORM
|| backbuffer_format
== WINED3DFMT_B8G8R8A8_UNORM
))
4222 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4223 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4224 return WINED3DERR_NOTAVAILABLE
;
4227 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode and it
4228 * can only be mixed with backbuffer format WINED3DFMT_B10G10R10A2_UNORM. */
4229 if (display_format
== WINED3DFMT_B10G10R10A2_UNORM
4230 && (backbuffer_format
!= WINED3DFMT_B10G10R10A2_UNORM
|| windowed
))
4232 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4233 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4234 return WINED3DERR_NOTAVAILABLE
;
4237 /* Use CheckDeviceFormat to see if the backbuffer_format is usable with the given display_format */
4238 hr
= wined3d_check_device_format(wined3d
, adapter_idx
, device_type
, display_format
,
4239 WINED3DUSAGE_RENDERTARGET
, WINED3DRTYPE_SURFACE
, backbuffer_format
, SURFACE_OPENGL
);
4241 TRACE_(d3d_caps
)("Unsupported display/backbuffer format combination %s / %s.\n",
4242 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4247 /* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
4248 subset of a D3DCAPS9 structure. However, it has to come via a void *
4249 as the d3d8 interface cannot import the d3d9 header */
4250 HRESULT CDECL
wined3d_get_device_caps(const struct wined3d
*wined3d
, UINT adapter_idx
,
4251 WINED3DDEVTYPE device_type
, WINED3DCAPS
*caps
)
4253 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
4254 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
4255 int vs_selected_mode
;
4256 int ps_selected_mode
;
4257 struct shader_caps shader_caps
;
4258 struct fragment_caps fragment_caps
;
4259 DWORD ckey_caps
, blit_caps
, fx_caps
, pal_caps
;
4261 TRACE_(d3d_caps
)("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
4262 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), caps
);
4264 if (adapter_idx
>= wined3d
->adapter_count
)
4265 return WINED3DERR_INVALIDCALL
;
4267 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
4269 /* ------------------------------------------------
4270 The following fields apply to both d3d8 and d3d9
4271 ------------------------------------------------ */
4272 /* Not quite true, but use h/w supported by opengl I suppose */
4273 caps
->DeviceType
= (device_type
== WINED3DDEVTYPE_HAL
) ? WINED3DDEVTYPE_HAL
: WINED3DDEVTYPE_REF
;
4274 caps
->AdapterOrdinal
= adapter_idx
;
4277 caps
->Caps2
= WINED3DCAPS2_CANRENDERWINDOWED
|
4278 WINED3DCAPS2_FULLSCREENGAMMA
|
4279 WINED3DCAPS2_DYNAMICTEXTURES
;
4280 if (gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
4281 caps
->Caps2
|= WINED3DCAPS2_CANAUTOGENMIPMAP
;
4283 caps
->Caps3
= WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
4284 WINED3DCAPS3_COPY_TO_VIDMEM
|
4285 WINED3DCAPS3_COPY_TO_SYSTEMMEM
;
4287 caps
->PresentationIntervals
= WINED3DPRESENT_INTERVAL_IMMEDIATE
|
4288 WINED3DPRESENT_INTERVAL_ONE
;
4290 caps
->CursorCaps
= WINED3DCURSORCAPS_COLOR
|
4291 WINED3DCURSORCAPS_LOWRES
;
4293 caps
->DevCaps
= WINED3DDEVCAPS_FLOATTLVERTEX
|
4294 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY
|
4295 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
4296 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY
|
4297 WINED3DDEVCAPS_DRAWPRIMTLVERTEX
|
4298 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT
|
4299 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY
|
4300 WINED3DDEVCAPS_PUREDEVICE
|
4301 WINED3DDEVCAPS_HWRASTERIZATION
|
4302 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY
|
4303 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY
|
4304 WINED3DDEVCAPS_CANRENDERAFTERFLIP
|
4305 WINED3DDEVCAPS_DRAWPRIMITIVES2
|
4306 WINED3DDEVCAPS_DRAWPRIMITIVES2EX
|
4307 WINED3DDEVCAPS_RTPATCHES
;
4309 caps
->PrimitiveMiscCaps
= WINED3DPMISCCAPS_CULLNONE
|
4310 WINED3DPMISCCAPS_CULLCCW
|
4311 WINED3DPMISCCAPS_CULLCW
|
4312 WINED3DPMISCCAPS_COLORWRITEENABLE
|
4313 WINED3DPMISCCAPS_CLIPTLVERTS
|
4314 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
4315 WINED3DPMISCCAPS_MASKZ
|
4316 WINED3DPMISCCAPS_BLENDOP
|
4317 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
;
4319 WINED3DPMISCCAPS_NULLREFERENCE
4320 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
4321 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
4322 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
4324 if (gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
] && gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
4325 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_SEPARATEALPHABLEND
;
4326 if (gl_info
->supported
[EXT_DRAW_BUFFERS2
])
4327 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS
;
4329 caps
->RasterCaps
= WINED3DPRASTERCAPS_DITHER
|
4330 WINED3DPRASTERCAPS_PAT
|
4331 WINED3DPRASTERCAPS_WFOG
|
4332 WINED3DPRASTERCAPS_ZFOG
|
4333 WINED3DPRASTERCAPS_FOGVERTEX
|
4334 WINED3DPRASTERCAPS_FOGTABLE
|
4335 WINED3DPRASTERCAPS_STIPPLE
|
4336 WINED3DPRASTERCAPS_SUBPIXEL
|
4337 WINED3DPRASTERCAPS_ZTEST
|
4338 WINED3DPRASTERCAPS_SCISSORTEST
|
4339 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
4340 WINED3DPRASTERCAPS_DEPTHBIAS
;
4342 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4344 caps
->RasterCaps
|= WINED3DPRASTERCAPS_ANISOTROPY
|
4345 WINED3DPRASTERCAPS_ZBIAS
|
4346 WINED3DPRASTERCAPS_MIPMAPLODBIAS
;
4348 if (gl_info
->supported
[NV_FOG_DISTANCE
])
4350 caps
->RasterCaps
|= WINED3DPRASTERCAPS_FOGRANGE
;
4353 WINED3DPRASTERCAPS_COLORPERSPECTIVE
4354 WINED3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
4355 WINED3DPRASTERCAPS_ANTIALIASEDGES
4356 WINED3DPRASTERCAPS_ZBUFFERLESSHSR
4357 WINED3DPRASTERCAPS_WBUFFER */
4359 caps
->ZCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4360 WINED3DPCMPCAPS_EQUAL
|
4361 WINED3DPCMPCAPS_GREATER
|
4362 WINED3DPCMPCAPS_GREATEREQUAL
|
4363 WINED3DPCMPCAPS_LESS
|
4364 WINED3DPCMPCAPS_LESSEQUAL
|
4365 WINED3DPCMPCAPS_NEVER
|
4366 WINED3DPCMPCAPS_NOTEQUAL
;
4368 caps
->SrcBlendCaps
= WINED3DPBLENDCAPS_BOTHINVSRCALPHA
|
4369 WINED3DPBLENDCAPS_BOTHSRCALPHA
|
4370 WINED3DPBLENDCAPS_DESTALPHA
|
4371 WINED3DPBLENDCAPS_DESTCOLOR
|
4372 WINED3DPBLENDCAPS_INVDESTALPHA
|
4373 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4374 WINED3DPBLENDCAPS_INVSRCALPHA
|
4375 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4376 WINED3DPBLENDCAPS_ONE
|
4377 WINED3DPBLENDCAPS_SRCALPHA
|
4378 WINED3DPBLENDCAPS_SRCALPHASAT
|
4379 WINED3DPBLENDCAPS_SRCCOLOR
|
4380 WINED3DPBLENDCAPS_ZERO
;
4382 caps
->DestBlendCaps
= WINED3DPBLENDCAPS_DESTALPHA
|
4383 WINED3DPBLENDCAPS_DESTCOLOR
|
4384 WINED3DPBLENDCAPS_INVDESTALPHA
|
4385 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4386 WINED3DPBLENDCAPS_INVSRCALPHA
|
4387 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4388 WINED3DPBLENDCAPS_ONE
|
4389 WINED3DPBLENDCAPS_SRCALPHA
|
4390 WINED3DPBLENDCAPS_SRCCOLOR
|
4391 WINED3DPBLENDCAPS_ZERO
;
4392 /* NOTE: WINED3DPBLENDCAPS_SRCALPHASAT is not supported as dest blend factor,
4393 * according to the glBlendFunc manpage
4395 * WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA are
4396 * legacy settings for srcblend only
4399 if (gl_info
->supported
[EXT_BLEND_COLOR
])
4401 caps
->SrcBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4402 caps
->DestBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4406 caps
->AlphaCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4407 WINED3DPCMPCAPS_EQUAL
|
4408 WINED3DPCMPCAPS_GREATER
|
4409 WINED3DPCMPCAPS_GREATEREQUAL
|
4410 WINED3DPCMPCAPS_LESS
|
4411 WINED3DPCMPCAPS_LESSEQUAL
|
4412 WINED3DPCMPCAPS_NEVER
|
4413 WINED3DPCMPCAPS_NOTEQUAL
;
4415 caps
->ShadeCaps
= WINED3DPSHADECAPS_SPECULARGOURAUDRGB
|
4416 WINED3DPSHADECAPS_COLORGOURAUDRGB
|
4417 WINED3DPSHADECAPS_ALPHAFLATBLEND
|
4418 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND
|
4419 WINED3DPSHADECAPS_COLORFLATRGB
|
4420 WINED3DPSHADECAPS_FOGFLAT
|
4421 WINED3DPSHADECAPS_FOGGOURAUD
|
4422 WINED3DPSHADECAPS_SPECULARFLATRGB
;
4424 caps
->TextureCaps
= WINED3DPTEXTURECAPS_ALPHA
|
4425 WINED3DPTEXTURECAPS_ALPHAPALETTE
|
4426 WINED3DPTEXTURECAPS_TRANSPARENCY
|
4427 WINED3DPTEXTURECAPS_BORDER
|
4428 WINED3DPTEXTURECAPS_MIPMAP
|
4429 WINED3DPTEXTURECAPS_PROJECTED
|
4430 WINED3DPTEXTURECAPS_PERSPECTIVE
;
4432 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4434 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_POW2
|
4435 WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL
;
4438 if (gl_info
->supported
[EXT_TEXTURE3D
])
4440 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP
|
4441 WINED3DPTEXTURECAPS_MIPVOLUMEMAP
;
4442 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4444 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2
;
4448 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4450 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP
|
4451 WINED3DPTEXTURECAPS_MIPCUBEMAP
;
4452 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4454 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP_POW2
;
4458 caps
->TextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4459 WINED3DPTFILTERCAPS_MAGFPOINT
|
4460 WINED3DPTFILTERCAPS_MINFLINEAR
|
4461 WINED3DPTFILTERCAPS_MINFPOINT
|
4462 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4463 WINED3DPTFILTERCAPS_MIPFPOINT
|
4464 WINED3DPTFILTERCAPS_LINEAR
|
4465 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4466 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4467 WINED3DPTFILTERCAPS_MIPLINEAR
|
4468 WINED3DPTFILTERCAPS_MIPNEAREST
|
4469 WINED3DPTFILTERCAPS_NEAREST
;
4471 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4473 caps
->TextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4474 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4477 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4479 caps
->CubeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4480 WINED3DPTFILTERCAPS_MAGFPOINT
|
4481 WINED3DPTFILTERCAPS_MINFLINEAR
|
4482 WINED3DPTFILTERCAPS_MINFPOINT
|
4483 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4484 WINED3DPTFILTERCAPS_MIPFPOINT
|
4485 WINED3DPTFILTERCAPS_LINEAR
|
4486 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4487 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4488 WINED3DPTFILTERCAPS_MIPLINEAR
|
4489 WINED3DPTFILTERCAPS_MIPNEAREST
|
4490 WINED3DPTFILTERCAPS_NEAREST
;
4492 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4494 caps
->CubeTextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4495 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4500 caps
->CubeTextureFilterCaps
= 0;
4503 if (gl_info
->supported
[EXT_TEXTURE3D
])
4505 caps
->VolumeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4506 WINED3DPTFILTERCAPS_MAGFPOINT
|
4507 WINED3DPTFILTERCAPS_MINFLINEAR
|
4508 WINED3DPTFILTERCAPS_MINFPOINT
|
4509 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4510 WINED3DPTFILTERCAPS_MIPFPOINT
|
4511 WINED3DPTFILTERCAPS_LINEAR
|
4512 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4513 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4514 WINED3DPTFILTERCAPS_MIPLINEAR
|
4515 WINED3DPTFILTERCAPS_MIPNEAREST
|
4516 WINED3DPTFILTERCAPS_NEAREST
;
4520 caps
->VolumeTextureFilterCaps
= 0;
4523 caps
->TextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4524 WINED3DPTADDRESSCAPS_CLAMP
|
4525 WINED3DPTADDRESSCAPS_WRAP
;
4527 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4529 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4531 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4533 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4535 if (gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
4537 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4540 if (gl_info
->supported
[EXT_TEXTURE3D
])
4542 caps
->VolumeTextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4543 WINED3DPTADDRESSCAPS_CLAMP
|
4544 WINED3DPTADDRESSCAPS_WRAP
;
4545 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4547 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4549 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4551 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4553 if (gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
4555 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4560 caps
->VolumeTextureAddressCaps
= 0;
4563 caps
->LineCaps
= WINED3DLINECAPS_TEXTURE
|
4564 WINED3DLINECAPS_ZTEST
|
4565 WINED3DLINECAPS_BLEND
|
4566 WINED3DLINECAPS_ALPHACMP
|
4567 WINED3DLINECAPS_FOG
;
4568 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
4569 * idea how generating the smoothing alpha values works; the result is different
4572 caps
->MaxTextureWidth
= gl_info
->limits
.texture_size
;
4573 caps
->MaxTextureHeight
= gl_info
->limits
.texture_size
;
4575 if (gl_info
->supported
[EXT_TEXTURE3D
])
4576 caps
->MaxVolumeExtent
= gl_info
->limits
.texture3d_size
;
4578 caps
->MaxVolumeExtent
= 0;
4580 caps
->MaxTextureRepeat
= 32768;
4581 caps
->MaxTextureAspectRatio
= gl_info
->limits
.texture_size
;
4582 caps
->MaxVertexW
= 1.0f
;
4584 caps
->GuardBandLeft
= 0.0f
;
4585 caps
->GuardBandTop
= 0.0f
;
4586 caps
->GuardBandRight
= 0.0f
;
4587 caps
->GuardBandBottom
= 0.0f
;
4589 caps
->ExtentsAdjust
= 0.0f
;
4591 caps
->StencilCaps
= WINED3DSTENCILCAPS_DECRSAT
|
4592 WINED3DSTENCILCAPS_INCRSAT
|
4593 WINED3DSTENCILCAPS_INVERT
|
4594 WINED3DSTENCILCAPS_KEEP
|
4595 WINED3DSTENCILCAPS_REPLACE
|
4596 WINED3DSTENCILCAPS_ZERO
;
4597 if (gl_info
->supported
[EXT_STENCIL_WRAP
])
4599 caps
->StencilCaps
|= WINED3DSTENCILCAPS_DECR
|
4600 WINED3DSTENCILCAPS_INCR
;
4602 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
] || gl_info
->supported
[ATI_SEPARATE_STENCIL
])
4604 caps
->StencilCaps
|= WINED3DSTENCILCAPS_TWOSIDED
;
4607 caps
->FVFCaps
= WINED3DFVFCAPS_PSIZE
| 0x0008; /* 8 texture coords */
4609 caps
->MaxUserClipPlanes
= gl_info
->limits
.clipplanes
;
4610 caps
->MaxActiveLights
= gl_info
->limits
.lights
;
4612 caps
->MaxVertexBlendMatrices
= gl_info
->limits
.blends
;
4613 caps
->MaxVertexBlendMatrixIndex
= 0;
4615 caps
->MaxAnisotropy
= gl_info
->limits
.anisotropy
;
4616 caps
->MaxPointSize
= gl_info
->limits
.pointsize_max
;
4619 /* FIXME: Add D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */
4620 caps
->VertexProcessingCaps
= WINED3DVTXPCAPS_DIRECTIONALLIGHTS
|
4621 WINED3DVTXPCAPS_MATERIALSOURCE7
|
4622 WINED3DVTXPCAPS_POSITIONALLIGHTS
|
4623 WINED3DVTXPCAPS_LOCALVIEWER
|
4624 WINED3DVTXPCAPS_VERTEXFOG
|
4625 WINED3DVTXPCAPS_TEXGEN
;
4627 caps
->MaxPrimitiveCount
= 0xFFFFF; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
4628 caps
->MaxVertexIndex
= 0xFFFFF;
4629 caps
->MaxStreams
= MAX_STREAMS
;
4630 caps
->MaxStreamStride
= 1024;
4632 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
4633 caps
->DevCaps2
= WINED3DDEVCAPS2_STREAMOFFSET
|
4634 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
;
4635 caps
->MaxNpatchTessellationLevel
= 0;
4636 caps
->MasterAdapterOrdinal
= 0;
4637 caps
->AdapterOrdinalInGroup
= 0;
4638 caps
->NumberOfAdaptersInGroup
= 1;
4640 caps
->NumSimultaneousRTs
= gl_info
->limits
.buffers
;
4642 caps
->StretchRectFilterCaps
= WINED3DPTFILTERCAPS_MINFPOINT
|
4643 WINED3DPTFILTERCAPS_MAGFPOINT
|
4644 WINED3DPTFILTERCAPS_MINFLINEAR
|
4645 WINED3DPTFILTERCAPS_MAGFLINEAR
;
4646 caps
->VertexTextureFilterCaps
= 0;
4648 adapter
->shader_backend
->shader_get_caps(&adapter
->gl_info
, &shader_caps
);
4649 adapter
->fragment_pipe
->get_caps(&adapter
->gl_info
, &fragment_caps
);
4651 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
4652 caps
->PrimitiveMiscCaps
|= fragment_caps
.PrimitiveMiscCaps
;
4654 /* This takes care for disabling vertex shader or pixel shader caps while leaving the other one enabled.
4655 * Ignore shader model capabilities if disabled in config
4657 if (vs_selected_mode
== SHADER_NONE
)
4659 TRACE_(d3d_caps
)("Vertex shader disabled in config, reporting version 0.0\n");
4660 caps
->VertexShaderVersion
= WINED3DVS_VERSION(0,0);
4661 caps
->MaxVertexShaderConst
= 0;
4665 caps
->VertexShaderVersion
= shader_caps
.VertexShaderVersion
;
4666 caps
->MaxVertexShaderConst
= shader_caps
.MaxVertexShaderConst
;
4669 if (ps_selected_mode
== SHADER_NONE
)
4671 TRACE_(d3d_caps
)("Pixel shader disabled in config, reporting version 0.0\n");
4672 caps
->PixelShaderVersion
= WINED3DPS_VERSION(0,0);
4673 caps
->PixelShader1xMaxValue
= 0.0f
;
4675 caps
->PixelShaderVersion
= shader_caps
.PixelShaderVersion
;
4676 caps
->PixelShader1xMaxValue
= shader_caps
.PixelShader1xMaxValue
;
4679 caps
->TextureOpCaps
= fragment_caps
.TextureOpCaps
;
4680 caps
->MaxTextureBlendStages
= fragment_caps
.MaxTextureBlendStages
;
4681 caps
->MaxSimultaneousTextures
= fragment_caps
.MaxSimultaneousTextures
;
4683 /* The following caps are shader specific, but they are things we cannot detect, or which
4684 * are the same among all shader models. So to avoid code duplication set the shader version
4685 * specific, but otherwise constant caps here
4687 if (caps
->VertexShaderVersion
== WINED3DVS_VERSION(3,0))
4689 /* Where possible set the caps based on OpenGL extensions and if they
4690 * aren't set (in case of software rendering) use the VS 3.0 from
4691 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4693 caps
->VS20Caps
.Caps
= WINED3DVS20CAPS_PREDICATION
;
4694 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4695 caps
->VS20Caps
.DynamicFlowControlDepth
= WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4696 caps
->VS20Caps
.NumTemps
= max(32, adapter
->gl_info
.limits
.arb_vs_temps
);
4697 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
4698 caps
->VS20Caps
.StaticFlowControlDepth
= WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
4700 caps
->MaxVShaderInstructionsExecuted
= 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
4701 caps
->MaxVertexShader30InstructionSlots
= max(512, adapter
->gl_info
.limits
.arb_vs_instructions
);
4703 else if (caps
->VertexShaderVersion
== WINED3DVS_VERSION(2,0))
4705 caps
->VS20Caps
.Caps
= 0;
4706 caps
->VS20Caps
.DynamicFlowControlDepth
= WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
;
4707 caps
->VS20Caps
.NumTemps
= max(12, adapter
->gl_info
.limits
.arb_vs_temps
);
4708 caps
->VS20Caps
.StaticFlowControlDepth
= 1;
4710 caps
->MaxVShaderInstructionsExecuted
= 65535;
4711 caps
->MaxVertexShader30InstructionSlots
= 0;
4715 caps
->VS20Caps
.Caps
= 0;
4716 caps
->VS20Caps
.DynamicFlowControlDepth
= 0;
4717 caps
->VS20Caps
.NumTemps
= 0;
4718 caps
->VS20Caps
.StaticFlowControlDepth
= 0;
4720 caps
->MaxVShaderInstructionsExecuted
= 0;
4721 caps
->MaxVertexShader30InstructionSlots
= 0;
4724 if (caps
->PixelShaderVersion
== WINED3DPS_VERSION(3,0))
4726 /* Where possible set the caps based on OpenGL extensions and if they
4727 * aren't set (in case of software rendering) use the PS 3.0 from
4728 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4731 /* Caps is more or less undocumented on MSDN but it appears to be
4732 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
4733 * cards from Windows */
4734 caps
->PS20Caps
.Caps
= WINED3DPS20CAPS_ARBITRARYSWIZZLE
|
4735 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS
|
4736 WINED3DPS20CAPS_PREDICATION
|
4737 WINED3DPS20CAPS_NODEPENDENTREADLIMIT
|
4738 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
4739 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4740 caps
->PS20Caps
.DynamicFlowControlDepth
= WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4741 caps
->PS20Caps
.NumTemps
= max(32, adapter
->gl_info
.limits
.arb_ps_temps
);
4742 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
4743 caps
->PS20Caps
.StaticFlowControlDepth
= WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
4744 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
4745 caps
->PS20Caps
.NumInstructionSlots
= WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
4747 caps
->MaxPShaderInstructionsExecuted
= 65535;
4748 caps
->MaxPixelShader30InstructionSlots
= max(WINED3DMIN30SHADERINSTRUCTIONS
,
4749 adapter
->gl_info
.limits
.arb_ps_instructions
);
4751 else if(caps
->PixelShaderVersion
== WINED3DPS_VERSION(2,0))
4753 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
4754 caps
->PS20Caps
.Caps
= 0;
4755 caps
->PS20Caps
.DynamicFlowControlDepth
= 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
4756 caps
->PS20Caps
.NumTemps
= max(12, adapter
->gl_info
.limits
.arb_ps_temps
);
4757 caps
->PS20Caps
.StaticFlowControlDepth
= WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH
; /* Minimum: 1 */
4758 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
4759 caps
->PS20Caps
.NumInstructionSlots
= WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS
;
4761 caps
->MaxPShaderInstructionsExecuted
= 512; /* Minimum value, a GeforceFX uses 1024 */
4762 caps
->MaxPixelShader30InstructionSlots
= 0;
4766 caps
->PS20Caps
.Caps
= 0;
4767 caps
->PS20Caps
.DynamicFlowControlDepth
= 0;
4768 caps
->PS20Caps
.NumTemps
= 0;
4769 caps
->PS20Caps
.StaticFlowControlDepth
= 0;
4770 caps
->PS20Caps
.NumInstructionSlots
= 0;
4772 caps
->MaxPShaderInstructionsExecuted
= 0;
4773 caps
->MaxPixelShader30InstructionSlots
= 0;
4776 if (caps
->VertexShaderVersion
>= WINED3DVS_VERSION(2,0))
4778 /* OpenGL supports all the formats below, perhaps not always
4779 * without conversion, but it supports them.
4780 * Further GLSL doesn't seem to have an official unsigned type so
4781 * don't advertise it yet as I'm not sure how we handle it.
4782 * We might need to add some clamping in the shader engine to
4784 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
4785 caps
->DeclTypes
= WINED3DDTCAPS_UBYTE4
|
4786 WINED3DDTCAPS_UBYTE4N
|
4787 WINED3DDTCAPS_SHORT2N
|
4788 WINED3DDTCAPS_SHORT4N
;
4789 if (gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
])
4791 caps
->DeclTypes
|= WINED3DDTCAPS_FLOAT16_2
|
4792 WINED3DDTCAPS_FLOAT16_4
;
4797 caps
->DeclTypes
= 0;
4800 /* Set DirectDraw helper Caps */
4801 ckey_caps
= WINEDDCKEYCAPS_DESTBLT
|
4802 WINEDDCKEYCAPS_SRCBLT
;
4803 fx_caps
= WINEDDFXCAPS_BLTALPHA
|
4804 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT
|
4805 WINEDDFXCAPS_BLTMIRRORUPDOWN
|
4806 WINEDDFXCAPS_BLTROTATION90
|
4807 WINEDDFXCAPS_BLTSHRINKX
|
4808 WINEDDFXCAPS_BLTSHRINKXN
|
4809 WINEDDFXCAPS_BLTSHRINKY
|
4810 WINEDDFXCAPS_BLTSHRINKXN
|
4811 WINEDDFXCAPS_BLTSTRETCHX
|
4812 WINEDDFXCAPS_BLTSTRETCHXN
|
4813 WINEDDFXCAPS_BLTSTRETCHY
|
4814 WINEDDFXCAPS_BLTSTRETCHYN
;
4815 blit_caps
= WINEDDCAPS_BLT
|
4816 WINEDDCAPS_BLTCOLORFILL
|
4817 WINEDDCAPS_BLTDEPTHFILL
|
4818 WINEDDCAPS_BLTSTRETCH
|
4819 WINEDDCAPS_CANBLTSYSMEM
|
4820 WINEDDCAPS_CANCLIP
|
4821 WINEDDCAPS_CANCLIPSTRETCHED
|
4822 WINEDDCAPS_COLORKEY
|
4823 WINEDDCAPS_COLORKEYHWASSIST
|
4824 WINEDDCAPS_ALIGNBOUNDARYSRC
;
4825 pal_caps
= WINEDDPCAPS_8BIT
|
4826 WINEDDPCAPS_PRIMARYSURFACE
;
4828 /* Fill the ddraw caps structure */
4829 caps
->DirectDrawCaps
.Caps
= WINEDDCAPS_GDI
|
4830 WINEDDCAPS_PALETTE
|
4832 caps
->DirectDrawCaps
.Caps2
= WINEDDCAPS2_CERTIFIED
|
4833 WINEDDCAPS2_NOPAGELOCKREQUIRED
|
4834 WINEDDCAPS2_PRIMARYGAMMA
|
4835 WINEDDCAPS2_WIDESURFACES
|
4836 WINEDDCAPS2_CANRENDERWINDOWED
;
4837 caps
->DirectDrawCaps
.CKeyCaps
= ckey_caps
;
4838 caps
->DirectDrawCaps
.FXCaps
= fx_caps
;
4839 caps
->DirectDrawCaps
.PalCaps
= pal_caps
;
4840 caps
->DirectDrawCaps
.SVBCaps
= blit_caps
;
4841 caps
->DirectDrawCaps
.SVBCKeyCaps
= ckey_caps
;
4842 caps
->DirectDrawCaps
.SVBFXCaps
= fx_caps
;
4843 caps
->DirectDrawCaps
.VSBCaps
= blit_caps
;
4844 caps
->DirectDrawCaps
.VSBCKeyCaps
= ckey_caps
;
4845 caps
->DirectDrawCaps
.VSBFXCaps
= fx_caps
;
4846 caps
->DirectDrawCaps
.SSBCaps
= blit_caps
;
4847 caps
->DirectDrawCaps
.SSBCKeyCaps
= ckey_caps
;
4848 caps
->DirectDrawCaps
.SSBFXCaps
= fx_caps
;
4850 caps
->DirectDrawCaps
.ddsCaps
= WINEDDSCAPS_ALPHA
|
4851 WINEDDSCAPS_BACKBUFFER
|
4853 WINEDDSCAPS_FRONTBUFFER
|
4854 WINEDDSCAPS_OFFSCREENPLAIN
|
4855 WINEDDSCAPS_PALETTE
|
4856 WINEDDSCAPS_PRIMARYSURFACE
|
4857 WINEDDSCAPS_SYSTEMMEMORY
|
4858 WINEDDSCAPS_VIDEOMEMORY
|
4859 WINEDDSCAPS_VISIBLE
;
4860 caps
->DirectDrawCaps
.StrideAlign
= DDRAW_PITCH_ALIGNMENT
;
4862 /* Set D3D caps if OpenGL is available. */
4863 if (adapter
->opengl
)
4865 caps
->DirectDrawCaps
.ddsCaps
|= WINEDDSCAPS_3DDEVICE
|
4866 WINEDDSCAPS_MIPMAP
|
4867 WINEDDSCAPS_TEXTURE
|
4868 WINEDDSCAPS_ZBUFFER
;
4869 caps
->DirectDrawCaps
.Caps
|= WINEDDCAPS_3D
;
4875 HRESULT CDECL
wined3d_device_create(struct wined3d
*wined3d
, UINT adapter_idx
, WINED3DDEVTYPE device_type
,
4876 HWND focus_window
, DWORD flags
, BYTE surface_alignment
, struct wined3d_device_parent
*device_parent
,
4877 struct wined3d_device
**device
)
4879 struct wined3d_device
*object
;
4882 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, device_parent %p, device %p.\n",
4883 wined3d
, adapter_idx
, device_type
, focus_window
, flags
, device_parent
, device
);
4885 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
4886 * number and create a device without a 3D adapter for 2D only operation. */
4887 if (wined3d
->adapter_count
&& adapter_idx
>= wined3d
->adapter_count
)
4888 return WINED3DERR_INVALIDCALL
;
4890 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
4893 ERR("Failed to allocate device memory.\n");
4894 return E_OUTOFMEMORY
;
4897 hr
= device_init(object
, wined3d
, adapter_idx
, device_type
,
4898 focus_window
, flags
, surface_alignment
, device_parent
);
4901 WARN("Failed to initialize device, hr %#x.\n", hr
);
4902 HeapFree(GetProcessHeap(), 0, object
);
4906 TRACE("Created device %p.\n", object
);
4909 device_parent
->ops
->wined3d_device_created(device_parent
, *device
);
4914 void * CDECL
wined3d_get_parent(const struct wined3d
*wined3d
)
4916 TRACE("wined3d %p.\n", wined3d
);
4918 return wined3d
->parent
;
4921 static void WINE_GLAPI
invalid_func(const void *data
)
4923 ERR("Invalid vertex attribute function called\n");
4927 static void WINE_GLAPI
invalid_texcoord_func(GLenum unit
, const void *data
)
4929 ERR("Invalid texcoord function called\n");
4933 /* Helper functions for providing vertex data to opengl. The arrays are initialized based on
4934 * the extension detection and are used in drawStridedSlow
4936 static void WINE_GLAPI
position_d3dcolor(const void *data
)
4938 DWORD pos
= *((const DWORD
*)data
);
4940 FIXME("Add a test for fixed function position from d3dcolor type\n");
4941 glVertex4s(D3DCOLOR_B_R(pos
),
4947 static void WINE_GLAPI
position_float4(const void *data
)
4949 const GLfloat
*pos
= data
;
4951 if (pos
[3] != 0.0f
&& pos
[3] != 1.0f
)
4953 float w
= 1.0f
/ pos
[3];
4955 glVertex4f(pos
[0] * w
, pos
[1] * w
, pos
[2] * w
, w
);
4963 static void WINE_GLAPI
diffuse_d3dcolor(const void *data
)
4965 DWORD diffuseColor
= *((const DWORD
*)data
);
4967 glColor4ub(D3DCOLOR_B_R(diffuseColor
),
4968 D3DCOLOR_B_G(diffuseColor
),
4969 D3DCOLOR_B_B(diffuseColor
),
4970 D3DCOLOR_B_A(diffuseColor
));
4973 static void WINE_GLAPI
specular_d3dcolor(const void *data
)
4975 DWORD specularColor
= *((const DWORD
*)data
);
4976 GLbyte d
[] = {D3DCOLOR_B_R(specularColor
),
4977 D3DCOLOR_B_G(specularColor
),
4978 D3DCOLOR_B_B(specularColor
)};
4980 specular_func_3ubv(d
);
4983 static void WINE_GLAPI
warn_no_specular_func(const void *data
)
4985 WARN("GL_EXT_secondary_color not supported\n");
4988 static void fillGLAttribFuncs(const struct wined3d_gl_info
*gl_info
)
4990 position_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
4991 position_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
4992 position_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glVertex3fv
;
4993 position_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = position_float4
;
4994 position_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = position_d3dcolor
;
4995 position_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
4996 position_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
4997 position_funcs
[WINED3D_FFP_EMIT_SHORT4
] = (glAttribFunc
)glVertex2sv
;
4998 position_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
4999 position_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5000 position_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5001 position_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5002 position_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5003 position_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5004 position_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5005 position_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5006 position_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5008 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5009 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5010 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glColor3fv
;
5011 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glAttribFunc
)glColor4fv
;
5012 diffuse_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = diffuse_d3dcolor
;
5013 diffuse_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5014 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5015 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5016 diffuse_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = (glAttribFunc
)glColor4ubv
;
5017 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5018 diffuse_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = (glAttribFunc
)glColor4sv
;
5019 diffuse_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5020 diffuse_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = (glAttribFunc
)glColor4usv
;
5021 diffuse_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5022 diffuse_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5023 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5024 diffuse_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5026 /* No 4 component entry points here */
5027 specular_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5028 specular_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5029 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
5031 specular_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)GL_EXTCALL(glSecondaryColor3fvEXT
);
5035 specular_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = warn_no_specular_func
;
5037 specular_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = invalid_func
;
5038 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
5040 specular_func_3ubv
= (glAttribFunc
)GL_EXTCALL(glSecondaryColor3ubvEXT
);
5041 specular_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = specular_d3dcolor
;
5045 specular_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = warn_no_specular_func
;
5047 specular_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5048 specular_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5049 specular_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5050 specular_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5051 specular_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5052 specular_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5053 specular_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5054 specular_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5055 specular_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5056 specular_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5057 specular_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5058 specular_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5060 /* Only 3 component entry points here. Test how others behave. Float4 normals are used
5061 * by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
5063 normal_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
5064 normal_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
5065 normal_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glAttribFunc
)glNormal3fv
;
5066 normal_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glAttribFunc
)glNormal3fv
; /* Just ignore the 4th value */
5067 normal_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_func
;
5068 normal_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
5069 normal_funcs
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
5070 normal_funcs
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
5071 normal_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
5072 normal_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
5073 normal_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
5074 normal_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
5075 normal_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
5076 normal_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
5077 normal_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
5078 normal_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
5079 normal_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
5081 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT1
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord1fvARB
);
5082 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2fvARB
);
5083 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT3
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord3fvARB
);
5084 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4fvARB
);
5085 multi_texcoord_funcs
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_texcoord_func
;
5086 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_texcoord_func
;
5087 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2svARB
);
5088 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4svARB
);
5089 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_texcoord_func
;
5090 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_texcoord_func
;
5091 multi_texcoord_funcs
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_texcoord_func
;
5092 multi_texcoord_funcs
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_texcoord_func
;
5093 multi_texcoord_funcs
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_texcoord_func
;
5094 multi_texcoord_funcs
[WINED3D_FFP_EMIT_UDEC3
] = invalid_texcoord_func
;
5095 multi_texcoord_funcs
[WINED3D_FFP_EMIT_DEC3N
] = invalid_texcoord_func
;
5096 if (gl_info
->supported
[NV_HALF_FLOAT
])
5098 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT */
5099 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord2hvNV
);
5100 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = (glMultiTexCoordFunc
)GL_EXTCALL(glMultiTexCoord4hvNV
);
5102 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_texcoord_func
;
5103 multi_texcoord_funcs
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_texcoord_func
;
5107 /* Do not call while under the GL lock. */
5108 static BOOL
InitAdapters(struct wined3d
*wined3d
)
5110 static HMODULE mod_gl
;
5112 int ps_selected_mode
, vs_selected_mode
;
5114 /* No need to hold any lock. The calling library makes sure only one thread calls
5115 * wined3d simultaneously
5118 TRACE("Initializing adapters\n");
5121 #ifdef USE_WIN32_OPENGL
5122 #define USE_GL_FUNC(pfn) pfn = (void*)GetProcAddress(mod_gl, #pfn);
5123 mod_gl
= LoadLibraryA("opengl32.dll");
5125 ERR("Can't load opengl32.dll!\n");
5129 #define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);
5130 /* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 (glXGetProcAddress wrapper) instead of opengl32's */
5131 mod_gl
= GetModuleHandleA("gdi32.dll");
5135 /* Load WGL core functions from opengl32.dll */
5136 #define USE_WGL_FUNC(pfn) p##pfn = (void*)GetProcAddress(mod_gl, #pfn);
5140 if(!pwglGetProcAddress
) {
5141 ERR("Unable to load wglGetProcAddress!\n");
5145 /* Dynamically load all GL core functions */
5149 /* Load glFinish and glFlush from opengl32.dll even if we're not using WIN32 opengl
5150 * otherwise because we have to use winex11.drv's override
5152 #ifdef USE_WIN32_OPENGL
5153 wglFinish
= (void*)GetProcAddress(mod_gl
, "glFinish");
5154 wglFlush
= (void*)GetProcAddress(mod_gl
, "glFlush");
5156 wglFinish
= (void*)pwglGetProcAddress("wglFinish");
5157 wglFlush
= (void*)pwglGetProcAddress("wglFlush");
5160 glEnableWINE
= glEnable
;
5161 glDisableWINE
= glDisable
;
5163 /* For now only one default adapter */
5165 struct wined3d_adapter
*adapter
= &wined3d
->adapters
[0];
5166 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
5167 struct wined3d_fake_gl_ctx fake_gl_ctx
= {0};
5168 struct wined3d_pixel_format
*cfgs
;
5172 DISPLAY_DEVICEW DisplayDevice
;
5175 TRACE("Initializing default adapter\n");
5176 adapter
->ordinal
= 0;
5177 adapter
->monitorPoint
.x
= -1;
5178 adapter
->monitorPoint
.y
= -1;
5180 if (!AllocateLocallyUniqueId(&adapter
->luid
))
5182 DWORD err
= GetLastError();
5183 ERR("Failed to set adapter LUID (%#x).\n", err
);
5186 TRACE("Allocated LUID %08x:%08x for adapter.\n",
5187 adapter
->luid
.HighPart
, adapter
->luid
.LowPart
);
5189 if (!WineD3D_CreateFakeGLContext(&fake_gl_ctx
))
5191 ERR("Failed to get a gl context for default adapter\n");
5195 ret
= wined3d_adapter_init_gl_caps(adapter
);
5197 ERR("Failed to initialize gl caps for default adapter\n");
5198 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5201 ret
= initPixelFormats(&adapter
->gl_info
, adapter
->driver_info
.vendor
);
5203 ERR("Failed to init gl formats\n");
5204 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5208 hdc
= fake_gl_ctx
.dc
;
5210 adapter
->TextureRam
= adapter
->driver_info
.vidmem
;
5211 adapter
->UsedTextureRam
= 0;
5212 TRACE("Emulating %dMB of texture ram\n", adapter
->TextureRam
/(1024*1024));
5214 /* Initialize the Adapter's DeviceName which is required for ChangeDisplaySettings and friends */
5215 DisplayDevice
.cb
= sizeof(DisplayDevice
);
5216 EnumDisplayDevicesW(NULL
, 0 /* Adapter 0 = iDevNum 0 */, &DisplayDevice
, 0);
5217 TRACE("DeviceName: %s\n", debugstr_w(DisplayDevice
.DeviceName
));
5218 strcpyW(adapter
->DeviceName
, DisplayDevice
.DeviceName
);
5220 if (gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
])
5227 attribute
= WGL_NUMBER_PIXEL_FORMATS_ARB
;
5228 GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, 0, 0, 1, &attribute
, &adapter
->nCfgs
));
5230 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, adapter
->nCfgs
* sizeof(*adapter
->cfgs
));
5231 cfgs
= adapter
->cfgs
;
5232 attribs
[nAttribs
++] = WGL_RED_BITS_ARB
;
5233 attribs
[nAttribs
++] = WGL_GREEN_BITS_ARB
;
5234 attribs
[nAttribs
++] = WGL_BLUE_BITS_ARB
;
5235 attribs
[nAttribs
++] = WGL_ALPHA_BITS_ARB
;
5236 attribs
[nAttribs
++] = WGL_COLOR_BITS_ARB
;
5237 attribs
[nAttribs
++] = WGL_DEPTH_BITS_ARB
;
5238 attribs
[nAttribs
++] = WGL_STENCIL_BITS_ARB
;
5239 attribs
[nAttribs
++] = WGL_DRAW_TO_WINDOW_ARB
;
5240 attribs
[nAttribs
++] = WGL_PIXEL_TYPE_ARB
;
5241 attribs
[nAttribs
++] = WGL_DOUBLE_BUFFER_ARB
;
5242 attribs
[nAttribs
++] = WGL_AUX_BUFFERS_ARB
;
5244 for (iPixelFormat
=1; iPixelFormat
<= adapter
->nCfgs
; ++iPixelFormat
)
5246 res
= GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0, nAttribs
, attribs
, values
));
5251 /* Cache the pixel format */
5252 cfgs
->iPixelFormat
= iPixelFormat
;
5253 cfgs
->redSize
= values
[0];
5254 cfgs
->greenSize
= values
[1];
5255 cfgs
->blueSize
= values
[2];
5256 cfgs
->alphaSize
= values
[3];
5257 cfgs
->colorSize
= values
[4];
5258 cfgs
->depthSize
= values
[5];
5259 cfgs
->stencilSize
= values
[6];
5260 cfgs
->windowDrawable
= values
[7];
5261 cfgs
->iPixelType
= values
[8];
5262 cfgs
->doubleBuffer
= values
[9];
5263 cfgs
->auxBuffers
= values
[10];
5265 cfgs
->numSamples
= 0;
5266 /* Check multisample support */
5267 if (gl_info
->supported
[ARB_MULTISAMPLE
])
5269 int attrib
[2] = {WGL_SAMPLE_BUFFERS_ARB
, WGL_SAMPLES_ARB
};
5271 if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0, 2, attrib
, value
))) {
5272 /* value[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether multisampling is supported.
5273 * value[1] = number of multi sample buffers*/
5275 cfgs
->numSamples
= value
[1];
5279 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5280 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
5281 cfgs
->iPixelFormat
, cfgs
->iPixelType
, cfgs
->doubleBuffer
,
5282 cfgs
->redSize
, cfgs
->greenSize
, cfgs
->blueSize
, cfgs
->alphaSize
,
5283 cfgs
->depthSize
, cfgs
->stencilSize
, cfgs
->numSamples
, cfgs
->windowDrawable
);
5289 int nCfgs
= DescribePixelFormat(hdc
, 0, 0, 0);
5290 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, nCfgs
* sizeof(*adapter
->cfgs
));
5291 adapter
->nCfgs
= 0; /* We won't accept all formats e.g. software accelerated ones will be skipped */
5293 cfgs
= adapter
->cfgs
;
5294 for(iPixelFormat
=1; iPixelFormat
<=nCfgs
; iPixelFormat
++)
5296 PIXELFORMATDESCRIPTOR ppfd
;
5298 res
= DescribePixelFormat(hdc
, iPixelFormat
, sizeof(PIXELFORMATDESCRIPTOR
), &ppfd
);
5302 /* We only want HW acceleration using an OpenGL ICD driver.
5303 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering
5304 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD driver (e.g. 3dfx minigl)
5306 if(ppfd
.dwFlags
& (PFD_GENERIC_FORMAT
| PFD_GENERIC_ACCELERATED
))
5308 TRACE("Skipping iPixelFormat=%d because it isn't ICD accelerated\n", iPixelFormat
);
5312 cfgs
->iPixelFormat
= iPixelFormat
;
5313 cfgs
->redSize
= ppfd
.cRedBits
;
5314 cfgs
->greenSize
= ppfd
.cGreenBits
;
5315 cfgs
->blueSize
= ppfd
.cBlueBits
;
5316 cfgs
->alphaSize
= ppfd
.cAlphaBits
;
5317 cfgs
->colorSize
= ppfd
.cColorBits
;
5318 cfgs
->depthSize
= ppfd
.cDepthBits
;
5319 cfgs
->stencilSize
= ppfd
.cStencilBits
;
5320 cfgs
->windowDrawable
= (ppfd
.dwFlags
& PFD_DRAW_TO_WINDOW
) ? 1 : 0;
5321 cfgs
->iPixelType
= (ppfd
.iPixelType
== PFD_TYPE_RGBA
) ? WGL_TYPE_RGBA_ARB
: WGL_TYPE_COLORINDEX_ARB
;
5322 cfgs
->doubleBuffer
= (ppfd
.dwFlags
& PFD_DOUBLEBUFFER
) ? 1 : 0;
5323 cfgs
->auxBuffers
= ppfd
.cAuxBuffers
;
5324 cfgs
->numSamples
= 0;
5326 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5327 "depth=%d, stencil=%d, windowDrawable=%d\n",
5328 cfgs
->iPixelFormat
, cfgs
->iPixelType
, cfgs
->doubleBuffer
,
5329 cfgs
->redSize
, cfgs
->greenSize
, cfgs
->blueSize
, cfgs
->alphaSize
,
5330 cfgs
->depthSize
, cfgs
->stencilSize
, cfgs
->windowDrawable
);
5335 /* 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 */
5338 ERR("Disabling Direct3D because no hardware accelerated pixel formats have been found!\n");
5340 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5341 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
5346 /* D16, D24X8 and D24S8 are common depth / depth+stencil formats. All drivers support them though this doesn't
5347 * mean that the format is offered in hardware. For instance Geforce8 cards don't have offer D16 in hardware
5348 * but just fake it using D24(X8?) which is fine. D3D also allows that.
5349 * Some display drivers (i915 on Linux) only report mixed depth+stencil formats like D24S8. MSDN clearly mentions
5350 * that only on lockable formats (e.g. D16_locked) the bit order is guaranteed and that on other formats the
5351 * driver is allowed to consume more bits EXCEPT for stencil bits.
5353 * Mark an adapter with this broken stencil behavior.
5355 adapter
->brokenStencil
= TRUE
;
5356 for (i
= 0, cfgs
= adapter
->cfgs
; i
< adapter
->nCfgs
; ++i
)
5358 /* Nearly all drivers offer depth formats without stencil, only on i915 this if-statement won't be entered. */
5359 if(cfgs
[i
].depthSize
&& !cfgs
[i
].stencilSize
) {
5360 adapter
->brokenStencil
= FALSE
;
5365 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx
);
5367 select_shader_mode(&adapter
->gl_info
, &ps_selected_mode
, &vs_selected_mode
);
5368 fillGLAttribFuncs(&adapter
->gl_info
);
5369 adapter
->opengl
= TRUE
;
5371 wined3d
->adapter_count
= 1;
5372 TRACE("%u adapters successfully initialized.\n", wined3d
->adapter_count
);
5377 /* Initialize an adapter for ddraw-only memory counting */
5378 memset(wined3d
->adapters
, 0, sizeof(wined3d
->adapters
));
5379 wined3d
->adapters
[0].ordinal
= 0;
5380 wined3d
->adapters
[0].opengl
= FALSE
;
5381 wined3d
->adapters
[0].monitorPoint
.x
= -1;
5382 wined3d
->adapters
[0].monitorPoint
.y
= -1;
5384 wined3d
->adapters
[0].driver_info
.name
= "Display";
5385 wined3d
->adapters
[0].driver_info
.description
= "WineD3D DirectDraw Emulation";
5386 if (wined3d_settings
.emulated_textureram
)
5387 wined3d
->adapters
[0].TextureRam
= wined3d_settings
.emulated_textureram
;
5389 wined3d
->adapters
[0].TextureRam
= 8 * 1024 * 1024; /* This is plenty for a DDraw-only card */
5391 initPixelFormatsNoGL(&wined3d
->adapters
[0].gl_info
);
5393 wined3d
->adapter_count
= 1;
5397 static void STDMETHODCALLTYPE
wined3d_null_wined3d_object_destroyed(void *parent
) {}
5399 const struct wined3d_parent_ops wined3d_null_parent_ops
=
5401 wined3d_null_wined3d_object_destroyed
,
5404 /* Do not call while under the GL lock. */
5405 HRESULT
wined3d_init(struct wined3d
*wined3d
, UINT version
, DWORD flags
, void *parent
)
5407 wined3d
->dxVersion
= version
;
5409 wined3d
->parent
= parent
;
5410 wined3d
->flags
= flags
;
5412 if (!InitAdapters(wined3d
))
5414 WARN("Failed to initialize adapters.\n");
5417 MESSAGE("Direct3D%u is not available without OpenGL.\n", version
);