shcore: Implement Get/SetProcessDpiAwareness().
[wine.git] / dlls / wined3d / directx.c
blob7deefaf82dcd882ea1c316f643c069650efd7023
1 /*
2 * Copyright 2002-2004 Jason Edmeades
3 * Copyright 2003-2004 Raphael Junqueira
4 * Copyright 2004 Christian Costa
5 * Copyright 2005 Oliver Stieber
6 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
7 * Copyright 2009-2011 Henri Verbeet for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
25 #include "wine/port.h"
27 #include <stdio.h>
29 #include "wined3d_private.h"
30 #include "winternl.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
33 WINE_DECLARE_DEBUG_CHANNEL(d3d_perf);
34 WINE_DECLARE_DEBUG_CHANNEL(winediag);
36 #define DEFAULT_REFRESH_RATE 0
38 /* The driver names reflect the lowest GPU supported
39 * by a certain driver, so DRIVER_AMD_R300 supports
40 * R3xx, R4xx and R5xx GPUs. */
41 enum wined3d_display_driver
43 DRIVER_AMD_RAGE_128PRO,
44 DRIVER_AMD_R100,
45 DRIVER_AMD_R300,
46 DRIVER_AMD_R600,
47 DRIVER_AMD_RX,
48 DRIVER_INTEL_GMA800,
49 DRIVER_INTEL_GMA900,
50 DRIVER_INTEL_GMA950,
51 DRIVER_INTEL_GMA3000,
52 DRIVER_INTEL_HD4000,
53 DRIVER_NVIDIA_TNT,
54 DRIVER_NVIDIA_GEFORCE2MX,
55 DRIVER_NVIDIA_GEFORCEFX,
56 DRIVER_NVIDIA_GEFORCE6,
57 DRIVER_NVIDIA_GEFORCE8,
58 DRIVER_VMWARE,
59 DRIVER_UNKNOWN
62 enum wined3d_driver_model
64 DRIVER_MODEL_GENERIC,
65 DRIVER_MODEL_WIN9X,
66 DRIVER_MODEL_NT40,
67 DRIVER_MODEL_NT5X,
68 DRIVER_MODEL_NT6X
71 enum wined3d_gl_vendor
73 GL_VENDOR_UNKNOWN,
74 GL_VENDOR_APPLE,
75 GL_VENDOR_FGLRX,
76 GL_VENDOR_MESA,
77 GL_VENDOR_NVIDIA,
80 enum wined3d_d3d_level
82 WINED3D_D3D_LEVEL_5,
83 WINED3D_D3D_LEVEL_6,
84 WINED3D_D3D_LEVEL_7,
85 WINED3D_D3D_LEVEL_8,
86 WINED3D_D3D_LEVEL_9_SM2,
87 WINED3D_D3D_LEVEL_9_SM3,
88 WINED3D_D3D_LEVEL_10,
89 WINED3D_D3D_LEVEL_11,
90 WINED3D_D3D_LEVEL_COUNT
93 /* The d3d device ID */
94 static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
96 /* Extension detection */
97 struct wined3d_extension_map
99 const char *extension_string;
100 enum wined3d_gl_extension extension;
103 static const struct wined3d_extension_map gl_extension_map[] =
105 /* APPLE */
106 {"GL_APPLE_fence", APPLE_FENCE },
107 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS },
108 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE },
109 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422 },
111 /* ARB */
112 {"GL_ARB_base_instance", ARB_BASE_INSTANCE },
113 {"GL_ARB_blend_func_extended", ARB_BLEND_FUNC_EXTENDED },
114 {"GL_ARB_clear_buffer_object", ARB_CLEAR_BUFFER_OBJECT },
115 {"GL_ARB_clear_texture", ARB_CLEAR_TEXTURE },
116 {"GL_ARB_clip_control", ARB_CLIP_CONTROL },
117 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT },
118 {"GL_ARB_compute_shader", ARB_COMPUTE_SHADER },
119 {"GL_ARB_conservative_depth", ARB_CONSERVATIVE_DEPTH },
120 {"GL_ARB_copy_buffer", ARB_COPY_BUFFER },
121 {"GL_ARB_copy_image", ARB_COPY_IMAGE },
122 {"GL_ARB_cull_distance", ARB_CULL_DISTANCE },
123 {"GL_ARB_debug_output", ARB_DEBUG_OUTPUT },
124 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT },
125 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE },
126 {"GL_ARB_derivative_control", ARB_DERIVATIVE_CONTROL },
127 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS },
128 {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX },
129 {"GL_ARB_draw_indirect", ARB_DRAW_INDIRECT },
130 {"GL_ARB_draw_instanced", ARB_DRAW_INSTANCED },
131 {"GL_ARB_ES2_compatibility", ARB_ES2_COMPATIBILITY },
132 {"GL_ARB_ES3_compatibility", ARB_ES3_COMPATIBILITY },
133 {"GL_ARB_explicit_attrib_location", ARB_EXPLICIT_ATTRIB_LOCATION },
134 {"GL_ARB_fragment_coord_conventions", ARB_FRAGMENT_COORD_CONVENTIONS},
135 {"GL_ARB_fragment_layer_viewport", ARB_FRAGMENT_LAYER_VIEWPORT },
136 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM },
137 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER },
138 {"GL_ARB_framebuffer_no_attachments", ARB_FRAMEBUFFER_NO_ATTACHMENTS},
139 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT },
140 {"GL_ARB_framebuffer_sRGB", ARB_FRAMEBUFFER_SRGB },
141 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4 },
142 {"GL_ARB_gpu_shader5", ARB_GPU_SHADER5 },
143 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL },
144 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX },
145 {"GL_ARB_instanced_arrays", ARB_INSTANCED_ARRAYS },
146 {"GL_ARB_internalformat_query", ARB_INTERNALFORMAT_QUERY },
147 {"GL_ARB_internalformat_query2", ARB_INTERNALFORMAT_QUERY2 },
148 {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT },
149 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE },
150 {"GL_ARB_multisample", ARB_MULTISAMPLE },
151 {"GL_ARB_multitexture", ARB_MULTITEXTURE },
152 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY },
153 {"GL_ARB_pipeline_statistics_query", ARB_PIPELINE_STATISTICS_QUERY },
154 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT },
155 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS },
156 {"GL_ARB_point_sprite", ARB_POINT_SPRITE },
157 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX },
158 {"GL_ARB_sampler_objects", ARB_SAMPLER_OBJECTS },
159 {"GL_ARB_seamless_cube_map", ARB_SEAMLESS_CUBE_MAP },
160 {"GL_ARB_shader_atomic_counters", ARB_SHADER_ATOMIC_COUNTERS },
161 {"GL_ARB_shader_bit_encoding", ARB_SHADER_BIT_ENCODING },
162 {"GL_ARB_shader_image_load_store", ARB_SHADER_IMAGE_LOAD_STORE },
163 {"GL_ARB_shader_image_size", ARB_SHADER_IMAGE_SIZE },
164 {"GL_ARB_shader_storage_buffer_object", ARB_SHADER_STORAGE_BUFFER_OBJECT},
165 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD },
166 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100 },
167 {"GL_ARB_shading_language_420pack", ARB_SHADING_LANGUAGE_420PACK },
168 {"GL_ARB_shading_language_packing", ARB_SHADING_LANGUAGE_PACKING },
169 {"GL_ARB_shadow", ARB_SHADOW },
170 {"GL_ARB_stencil_texturing", ARB_STENCIL_TEXTURING },
171 {"GL_ARB_sync", ARB_SYNC },
172 {"GL_ARB_tessellation_shader", ARB_TESSELLATION_SHADER },
173 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP },
174 {"GL_ARB_texture_buffer_object", ARB_TEXTURE_BUFFER_OBJECT },
175 {"GL_ARB_texture_buffer_range", ARB_TEXTURE_BUFFER_RANGE },
176 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION },
177 {"GL_ARB_texture_compression_bptc", ARB_TEXTURE_COMPRESSION_BPTC },
178 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC },
179 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP },
180 {"GL_ARB_texture_cube_map_array", ARB_TEXTURE_CUBE_MAP_ARRAY },
181 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE },
182 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3 },
183 {"GL_ARB_texture_filter_anisotropic", ARB_TEXTURE_FILTER_ANISOTROPIC},
184 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT },
185 {"GL_ARB_texture_gather", ARB_TEXTURE_GATHER },
186 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT },
187 {"GL_ARB_texture_mirror_clamp_to_edge", ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE},
188 {"GL_ARB_texture_multisample", ARB_TEXTURE_MULTISAMPLE },
189 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO },
190 {"GL_ARB_texture_query_levels", ARB_TEXTURE_QUERY_LEVELS },
191 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE },
192 {"GL_ARB_texture_rg", ARB_TEXTURE_RG },
193 {"GL_ARB_texture_rgb10_a2ui", ARB_TEXTURE_RGB10_A2UI },
194 {"GL_ARB_texture_storage", ARB_TEXTURE_STORAGE },
195 {"GL_ARB_texture_storage_multisample", ARB_TEXTURE_STORAGE_MULTISAMPLE},
196 {"GL_ARB_texture_swizzle", ARB_TEXTURE_SWIZZLE },
197 {"GL_ARB_texture_view", ARB_TEXTURE_VIEW },
198 {"GL_ARB_timer_query", ARB_TIMER_QUERY },
199 {"GL_ARB_transform_feedback2", ARB_TRANSFORM_FEEDBACK2 },
200 {"GL_ARB_transform_feedback3", ARB_TRANSFORM_FEEDBACK3 },
201 {"GL_ARB_uniform_buffer_object", ARB_UNIFORM_BUFFER_OBJECT },
202 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA },
203 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT },
204 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM },
205 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER },
206 {"GL_ARB_vertex_type_2_10_10_10_rev", ARB_VERTEX_TYPE_2_10_10_10_REV},
207 {"GL_ARB_viewport_array", ARB_VIEWPORT_ARRAY },
209 /* ATI */
210 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER },
211 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL },
212 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC },
213 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3 },
214 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE },
216 /* EXT */
217 {"GL_EXT_blend_color", EXT_BLEND_COLOR },
218 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE },
219 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE },
220 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX },
221 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT },
222 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST },
223 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2 },
224 {"GL_EXT_fog_coord", EXT_FOG_COORD },
225 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT },
226 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE },
227 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT },
228 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS },
229 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4 },
230 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL },
231 {"GL_EXT_packed_float", EXT_PACKED_FLOAT },
232 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS },
233 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX },
234 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR },
235 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE },
236 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP },
237 {"GL_EXT_texture3D", EXT_TEXTURE3D },
238 {"GL_EXT_texture_array", EXT_TEXTURE_ARRAY },
239 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC },
240 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC },
241 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE },
242 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3 },
243 {"GL_EXT_texture_filter_anisotropic", ARB_TEXTURE_FILTER_ANISOTROPIC},
244 {"GL_EXT_texture_integer", EXT_TEXTURE_INTEGER },
245 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS },
246 {"GL_EXT_texture_mirror_clamp", EXT_TEXTURE_MIRROR_CLAMP },
247 {"GL_EXT_texture_shared_exponent", EXT_TEXTURE_SHARED_EXPONENT },
248 {"GL_EXT_texture_snorm", EXT_TEXTURE_SNORM },
249 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB },
250 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE },
251 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA },
253 /* NV */
254 {"GL_NV_fence", NV_FENCE },
255 {"GL_NV_fog_distance", NV_FOG_DISTANCE },
256 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM },
257 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2 },
258 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION },
259 {"GL_NV_half_float", NV_HALF_FLOAT },
260 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT },
261 {"GL_NV_point_sprite", NV_POINT_SPRITE },
262 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS },
263 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2 },
264 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION },
265 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4 },
266 {"GL_NV_texture_shader", NV_TEXTURE_SHADER },
267 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2 },
268 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM },
269 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1 },
270 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2 },
271 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION },
272 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3 },
275 static const struct wined3d_extension_map wgl_extension_map[] =
277 {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT },
278 {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL },
279 {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH},
280 {"WGL_WINE_query_renderer", WGL_WINE_QUERY_RENDERER },
283 /**********************************************************
284 * Utility functions follow
285 **********************************************************/
287 const struct min_lookup minMipLookup[] =
289 /* NONE POINT LINEAR */
290 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
291 {{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
292 {{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
295 const GLenum magLookup[] =
297 /* NONE POINT LINEAR */
298 GL_NEAREST, GL_NEAREST, GL_LINEAR,
301 static void wined3d_caps_gl_ctx_destroy(const struct wined3d_caps_gl_ctx *ctx)
303 const struct wined3d_gl_info *gl_info = ctx->gl_info;
305 TRACE("Destroying caps GL context.\n");
307 /* Both glDeleteProgram and glDeleteBuffers silently ignore 0 IDs but
308 * this function might be called before the relevant function pointers
309 * in gl_info are initialized. */
310 if (ctx->test_program_id || ctx->test_vbo)
312 GL_EXTCALL(glDeleteProgram(ctx->test_program_id));
313 GL_EXTCALL(glDeleteBuffers(1, &ctx->test_vbo));
316 if (!wglMakeCurrent(NULL, NULL))
317 ERR("Failed to disable caps GL context.\n");
319 if (!wglDeleteContext(ctx->gl_ctx))
321 DWORD err = GetLastError();
322 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx->gl_ctx, err);
325 wined3d_release_dc(ctx->wnd, ctx->dc);
326 DestroyWindow(ctx->wnd);
328 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
329 ERR("Failed to restore previous GL context.\n");
332 static BOOL wined3d_caps_gl_ctx_create_attribs(struct wined3d_caps_gl_ctx *caps_gl_ctx,
333 struct wined3d_gl_info *gl_info)
335 HGLRC new_ctx;
337 if (!(gl_info->p_wglCreateContextAttribsARB = (void *)wglGetProcAddress("wglCreateContextAttribsARB")))
338 return TRUE;
340 if (!(new_ctx = context_create_wgl_attribs(gl_info, caps_gl_ctx->dc, NULL)))
342 gl_info->p_wglCreateContextAttribsARB = NULL;
343 return FALSE;
346 if (!wglMakeCurrent(caps_gl_ctx->dc, new_ctx))
348 ERR("Failed to make new context current, last error %#x.\n", GetLastError());
349 if (!wglDeleteContext(new_ctx))
350 ERR("Failed to delete new context, last error %#x.\n", GetLastError());
351 gl_info->p_wglCreateContextAttribsARB = NULL;
352 return TRUE;
355 if (!wglDeleteContext(caps_gl_ctx->gl_ctx))
356 ERR("Failed to delete old context, last error %#x.\n", GetLastError());
357 caps_gl_ctx->gl_ctx = new_ctx;
359 return TRUE;
362 static BOOL wined3d_caps_gl_ctx_create(struct wined3d_adapter *adapter, struct wined3d_caps_gl_ctx *ctx)
364 PIXELFORMATDESCRIPTOR pfd;
365 int iPixelFormat;
367 TRACE("getting context...\n");
369 ctx->restore_dc = wglGetCurrentDC();
370 ctx->restore_gl_ctx = wglGetCurrentContext();
372 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
373 ctx->wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
374 WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL);
375 if (!ctx->wnd)
377 ERR("Failed to create a window.\n");
378 goto fail;
381 ctx->dc = GetDC(ctx->wnd);
382 if (!ctx->dc)
384 ERR("Failed to get a DC.\n");
385 goto fail;
388 /* PixelFormat selection */
389 ZeroMemory(&pfd, sizeof(pfd));
390 pfd.nSize = sizeof(pfd);
391 pfd.nVersion = 1;
392 pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW; /* PFD_GENERIC_ACCELERATED */
393 pfd.iPixelType = PFD_TYPE_RGBA;
394 pfd.cColorBits = 32;
395 pfd.iLayerType = PFD_MAIN_PLANE;
397 if (!(iPixelFormat = ChoosePixelFormat(ctx->dc, &pfd)))
399 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
400 ERR("Failed to find a suitable pixel format.\n");
401 goto fail;
403 DescribePixelFormat(ctx->dc, iPixelFormat, sizeof(pfd), &pfd);
404 SetPixelFormat(ctx->dc, iPixelFormat, &pfd);
406 /* Create a GL context. */
407 if (!(ctx->gl_ctx = wglCreateContext(ctx->dc)))
409 WARN("Failed to create default context for capabilities initialization.\n");
410 goto fail;
413 /* Make it the current GL context. */
414 if (!wglMakeCurrent(ctx->dc, ctx->gl_ctx))
416 ERR("Failed to make caps GL context current.\n");
417 goto fail;
420 ctx->gl_info = &adapter->gl_info;
421 return TRUE;
423 fail:
424 if (ctx->gl_ctx) wglDeleteContext(ctx->gl_ctx);
425 ctx->gl_ctx = NULL;
426 if (ctx->dc) ReleaseDC(ctx->wnd, ctx->dc);
427 ctx->dc = NULL;
428 if (ctx->wnd) DestroyWindow(ctx->wnd);
429 ctx->wnd = NULL;
430 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
431 ERR("Failed to restore previous GL context.\n");
433 return FALSE;
436 /* Adjust the amount of used texture memory */
437 UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount)
439 adapter->vram_bytes_used += amount;
440 TRACE("Adjusted used adapter memory by 0x%s to 0x%s.\n",
441 wine_dbgstr_longlong(amount),
442 wine_dbgstr_longlong(adapter->vram_bytes_used));
443 return adapter->vram_bytes_used;
446 static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
448 heap_free(adapter->gl_info.formats);
449 heap_free(adapter->cfgs);
452 ULONG CDECL wined3d_incref(struct wined3d *wined3d)
454 ULONG refcount = InterlockedIncrement(&wined3d->ref);
456 TRACE("%p increasing refcount to %u.\n", wined3d, refcount);
458 return refcount;
461 ULONG CDECL wined3d_decref(struct wined3d *wined3d)
463 ULONG refcount = InterlockedDecrement(&wined3d->ref);
465 TRACE("%p decreasing refcount to %u.\n", wined3d, refcount);
467 if (!refcount)
469 unsigned int i;
471 for (i = 0; i < wined3d->adapter_count; ++i)
473 wined3d_adapter_cleanup(&wined3d->adapters[i]);
475 heap_free(wined3d);
478 return refcount;
481 /* Context activation is done by the caller. */
482 static BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
484 GLuint prog;
485 BOOL ret = FALSE;
486 static const char testcode[] =
487 "!!ARBvp1.0\n"
488 "PARAM C[66] = { program.env[0..65] };\n"
489 "ADDRESS A0;"
490 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
491 "ARL A0.x, zero.x;\n"
492 "MOV result.position, C[A0.x + 65];\n"
493 "END\n";
495 while (gl_info->gl_ops.gl.p_glGetError());
496 GL_EXTCALL(glGenProgramsARB(1, &prog));
497 if(!prog) {
498 ERR("Failed to create an ARB offset limit test program\n");
500 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
501 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
502 strlen(testcode), testcode));
503 if (gl_info->gl_ops.gl.p_glGetError())
505 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
506 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
507 ret = TRUE;
508 } else TRACE("OpenGL implementation allows offsets > 63\n");
510 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
511 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
512 checkGLcall("ARB vp offset limit test cleanup");
514 return ret;
517 static BOOL match_amd_r300_to_500(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
518 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
519 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
521 if (card_vendor != HW_VENDOR_AMD) return FALSE;
522 if (device == CARD_AMD_RADEON_9500) return TRUE;
523 if (device == CARD_AMD_RADEON_X700) return TRUE;
524 if (device == CARD_AMD_RADEON_X1600) return TRUE;
525 return FALSE;
528 static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
529 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
530 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
532 if (card_vendor == HW_VENDOR_NVIDIA)
534 if (device == CARD_NVIDIA_GEFORCEFX_5200 ||
535 device == CARD_NVIDIA_GEFORCEFX_5600 ||
536 device == CARD_NVIDIA_GEFORCEFX_5800)
538 return TRUE;
541 return FALSE;
544 static BOOL match_apple(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
545 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
546 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
548 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
549 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
550 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
552 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
553 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
554 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
555 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
556 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
557 * the chance that other implementations support them is rather small since Win32 QuickTime uses
558 * DirectDraw, not OpenGL.
560 * This test has been moved into wined3d_guess_gl_vendor()
562 return gl_vendor == GL_VENDOR_APPLE;
565 /* Context activation is done by the caller. */
566 static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
568 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
569 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
570 * all the texture. This function detects this bug by its symptom and disables PBOs
571 * if the test fails.
573 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
574 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
575 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
576 * read back is compared to the original. If they are equal PBOs are assumed to work,
577 * otherwise the PBO extension is disabled. */
578 GLuint texture, pbo;
579 static const unsigned int pattern[] =
581 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
582 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
583 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
584 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
586 unsigned int check[ARRAY_SIZE(pattern)];
588 /* No PBO -> No point in testing them. */
589 if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
591 while (gl_info->gl_ops.gl.p_glGetError());
592 gl_info->gl_ops.gl.p_glGenTextures(1, &texture);
593 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, texture);
595 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
596 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0);
597 checkGLcall("Specifying the PBO test texture");
599 GL_EXTCALL(glGenBuffers(1, &pbo));
600 GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo));
601 GL_EXTCALL(glBufferData(GL_PIXEL_UNPACK_BUFFER, sizeof(pattern), pattern, GL_STREAM_DRAW));
602 checkGLcall("Specifying the PBO test pbo");
604 gl_info->gl_ops.gl.p_glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
605 checkGLcall("Loading the PBO test texture");
607 GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
609 gl_info->gl_ops.gl.p_glFinish(); /* just to be sure */
611 memset(check, 0, sizeof(check));
612 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
613 checkGLcall("Reading back the PBO test texture");
615 gl_info->gl_ops.gl.p_glDeleteTextures(1, &texture);
616 GL_EXTCALL(glDeleteBuffers(1, &pbo));
617 checkGLcall("PBO test cleanup");
619 if (memcmp(check, pattern, sizeof(check)))
621 WARN_(d3d_perf)("PBO test failed, read back data doesn't match original.\n"
622 "Disabling PBOs. This may result in slower performance.\n");
623 gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] = FALSE;
625 else
627 TRACE("PBO test successful.\n");
631 static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
632 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
633 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
635 return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE);
638 static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
639 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
640 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
642 if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
643 if (card_vendor != HW_VENDOR_AMD) return FALSE;
644 if (device == CARD_AMD_RADEON_X1600) return FALSE;
645 return TRUE;
648 static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
649 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
650 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
652 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
653 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
654 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
655 * varyings and we subtract one in dx9 shaders it's not going to hurt us because the dx9 limit is
656 * hardcoded
658 * dx10 cards usually have 64 varyings */
659 return gl_info->limits.glsl_varyings > 44;
662 static BOOL match_not_dx10_capable(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
663 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
664 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
666 return !match_dx10_capable(gl_info, ctx, gl_renderer, gl_vendor, card_vendor, device);
669 /* A GL context is provided by the caller */
670 static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
671 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
672 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
674 GLenum error;
675 DWORD data[16];
677 if (!gl_info->supported[EXT_SECONDARY_COLOR])
678 return FALSE;
680 while (gl_info->gl_ops.gl.p_glGetError());
681 GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
682 error = gl_info->gl_ops.gl.p_glGetError();
684 if (error == GL_NO_ERROR)
686 TRACE("GL Implementation accepts 4 component specular color pointers\n");
687 return TRUE;
689 else
691 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
692 debug_glerror(error));
693 return FALSE;
697 /* A GL context is provided by the caller */
698 static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
699 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
700 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
702 GLuint prog;
703 BOOL ret = FALSE;
704 GLint pos;
705 static const char testcode[] =
706 "!!ARBvp1.0\n"
707 "OPTION NV_vertex_program2;\n"
708 "MOV result.clip[0], 0.0;\n"
709 "MOV result.position, 0.0;\n"
710 "END\n";
712 if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE;
714 while (gl_info->gl_ops.gl.p_glGetError());
716 GL_EXTCALL(glGenProgramsARB(1, &prog));
717 if(!prog)
719 ERR("Failed to create the NVvp clip test program\n");
720 return FALSE;
722 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
723 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
724 strlen(testcode), testcode));
725 gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
726 if(pos != -1)
728 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
729 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
730 ret = TRUE;
731 while (gl_info->gl_ops.gl.p_glGetError());
733 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
735 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
736 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
737 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
739 return ret;
742 /* Context activation is done by the caller. */
743 static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
744 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
745 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
747 char data[4 * 4 * 4];
748 GLuint tex, fbo;
749 GLenum status;
751 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE;
753 memset(data, 0xcc, sizeof(data));
755 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
756 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
757 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
758 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
759 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
760 checkGLcall("glTexImage2D");
762 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
763 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
764 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
765 checkGLcall("glFramebufferTexture2D");
767 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
768 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
769 checkGLcall("glCheckFramebufferStatus");
771 memset(data, 0x11, sizeof(data));
772 gl_info->gl_ops.gl.p_glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
773 checkGLcall("glTexSubImage2D");
775 gl_info->gl_ops.gl.p_glClearColor(0.996f, 0.729f, 0.745f, 0.792f);
776 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
777 checkGLcall("glClear");
779 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
780 checkGLcall("glGetTexImage");
782 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
783 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
784 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
785 checkGLcall("glBindTexture");
787 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
788 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
789 checkGLcall("glDeleteTextures");
791 return *(DWORD *)data == 0x11111111;
794 /* Context activation is done by the caller. */
795 static BOOL match_broken_rgba16(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
796 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
797 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
799 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
800 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
801 GLuint tex;
802 GLint size;
804 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
805 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
806 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL);
807 checkGLcall("glTexImage2D");
809 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &size);
810 checkGLcall("glGetTexLevelParameteriv");
811 TRACE("Real color depth is %d\n", size);
813 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
814 checkGLcall("glBindTexture");
815 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
816 checkGLcall("glDeleteTextures");
818 return size < 16;
821 static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
822 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
823 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
825 return gl_vendor == GL_VENDOR_FGLRX;
828 static BOOL match_r200(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
829 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
830 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
832 if (card_vendor != HW_VENDOR_AMD) return FALSE;
833 if (device == CARD_AMD_RADEON_8500) return TRUE;
834 return FALSE;
837 static BOOL match_broken_arb_fog(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
838 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
839 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
841 DWORD data[4];
842 GLuint tex, fbo;
843 GLenum status;
844 float color[4] = {0.0f, 1.0f, 0.0f, 0.0f};
845 GLuint prog;
846 GLint err_pos;
847 static const char program_code[] =
848 "!!ARBfp1.0\n"
849 "OPTION ARB_fog_linear;\n"
850 "MOV result.color, {1.0, 0.0, 0.0, 0.0};\n"
851 "END\n";
853 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
854 return FALSE;
855 if (!gl_info->supported[ARB_FRAGMENT_PROGRAM])
856 return FALSE;
858 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
859 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
860 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
861 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
862 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 4, 1, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
863 checkGLcall("glTexImage2D");
865 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
866 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
867 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
868 checkGLcall("glFramebufferTexture2D");
870 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
871 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
872 checkGLcall("glCheckFramebufferStatus");
874 gl_info->gl_ops.gl.p_glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
875 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
876 checkGLcall("glClear");
877 gl_info->gl_ops.gl.p_glViewport(0, 0, 4, 1);
878 checkGLcall("glViewport");
880 gl_info->gl_ops.gl.p_glEnable(GL_FOG);
881 gl_info->gl_ops.gl.p_glFogf(GL_FOG_START, 0.5f);
882 gl_info->gl_ops.gl.p_glFogf(GL_FOG_END, 0.5f);
883 gl_info->gl_ops.gl.p_glFogi(GL_FOG_MODE, GL_LINEAR);
884 gl_info->gl_ops.gl.p_glHint(GL_FOG_HINT, GL_NICEST);
885 gl_info->gl_ops.gl.p_glFogfv(GL_FOG_COLOR, color);
886 checkGLcall("fog setup");
888 GL_EXTCALL(glGenProgramsARB(1, &prog));
889 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog));
890 GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
891 strlen(program_code), program_code));
892 gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_PROGRAM_ARB);
893 checkGLcall("Test fragment program setup");
895 gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &err_pos);
896 if (err_pos != -1)
898 const char *error_str;
899 error_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB);
900 FIXME("Fog test program error at position %d: %s\n\n", err_pos, debugstr_a(error_str));
903 gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP);
904 gl_info->gl_ops.gl.p_glVertex3f(-1.0f, -1.0f, 0.0f);
905 gl_info->gl_ops.gl.p_glVertex3f( 1.0f, -1.0f, 1.0f);
906 gl_info->gl_ops.gl.p_glVertex3f(-1.0f, 1.0f, 0.0f);
907 gl_info->gl_ops.gl.p_glVertex3f( 1.0f, 1.0f, 1.0f);
908 gl_info->gl_ops.gl.p_glEnd();
909 checkGLcall("ARBfp fog test draw");
911 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
912 checkGLcall("glGetTexImage");
913 data[0] &= 0x00ffffff;
914 data[1] &= 0x00ffffff;
915 data[2] &= 0x00ffffff;
916 data[3] &= 0x00ffffff;
918 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
919 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
921 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
922 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
923 gl_info->gl_ops.gl.p_glDisable(GL_FOG);
924 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0));
925 gl_info->gl_ops.gl.p_glDisable(GL_FRAGMENT_PROGRAM_ARB);
926 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
927 checkGLcall("ARBfp fog test teardown");
929 TRACE("Fog test data: %08x %08x %08x %08x\n", data[0], data[1], data[2], data[3]);
930 return data[0] != 0x00ff0000 || data[3] != 0x0000ff00;
933 static BOOL match_broken_viewport_subpixel_bits(const struct wined3d_gl_info *gl_info,
934 struct wined3d_caps_gl_ctx *ctx, const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
935 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
937 if (!gl_info->supported[ARB_VIEWPORT_ARRAY])
938 return FALSE;
939 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
940 return FALSE;
941 return !wined3d_caps_gl_ctx_test_viewport_subpixel_bits(ctx);
944 static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
946 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
947 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
948 * allow 48 different offsets or other helper immediate values. */
949 TRACE("Reserving 12 GLSL constants for compiler private use.\n");
950 gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 12);
953 static void quirk_amd_dx9(struct wined3d_gl_info *gl_info)
955 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
956 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
957 * If real NP2 textures are used, the driver falls back to software. We could just remove the
958 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconvenient
959 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
960 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
961 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
963 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
964 * has this extension promoted to core. The extension loading code sets this extension supported
965 * due to that, so this code works on fglrx as well. */
966 if(gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
968 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
969 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
970 gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] = TRUE;
974 static void quirk_no_np2(struct wined3d_gl_info *gl_info)
976 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
977 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
978 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
979 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
980 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
981 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
983 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
984 * triggering the software fallback. There is not much we can do here apart from disabling the
985 * software-emulated extension and re-enable ARB_tex_rect (which was previously disabled
986 * in wined3d_adapter_init_gl_caps).
987 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
988 * post-processing effects in the game "Max Payne 2").
989 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
990 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
991 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
992 gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE;
995 static void quirk_texcoord_w(struct wined3d_gl_info *gl_info)
997 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
998 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
999 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
1000 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
1001 * according to the spec.
1003 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
1004 * makes the shader slower and eats instruction slots which should be available to the d3d app.
1006 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
1007 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
1008 * this workaround is activated on cards that do not need it, it won't break things, just affect
1009 * performance negatively. */
1010 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
1011 gl_info->quirks |= WINED3D_QUIRK_SET_TEXCOORD_W;
1014 static void quirk_clip_varying(struct wined3d_gl_info *gl_info)
1016 gl_info->quirks |= WINED3D_QUIRK_GLSL_CLIP_VARYING;
1019 static void quirk_allows_specular_alpha(struct wined3d_gl_info *gl_info)
1021 gl_info->quirks |= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA;
1024 static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info)
1026 gl_info->quirks |= WINED3D_QUIRK_NV_CLIP_BROKEN;
1029 static void quirk_fbo_tex_update(struct wined3d_gl_info *gl_info)
1031 gl_info->quirks |= WINED3D_QUIRK_FBO_TEX_UPDATE;
1034 static void quirk_broken_rgba16(struct wined3d_gl_info *gl_info)
1036 gl_info->quirks |= WINED3D_QUIRK_BROKEN_RGBA16;
1039 static void quirk_infolog_spam(struct wined3d_gl_info *gl_info)
1041 gl_info->quirks |= WINED3D_QUIRK_INFO_LOG_SPAM;
1044 static void quirk_limited_tex_filtering(struct wined3d_gl_info *gl_info)
1046 /* Nvidia GeForce 6xxx and 7xxx support accelerated VTF only on a few
1047 selected texture formats. They are apparently the only DX9 class GPUs
1048 supporting VTF.
1049 Also, DX9-era GPUs are somewhat limited with float textures
1050 filtering and blending. */
1051 gl_info->quirks |= WINED3D_QUIRK_LIMITED_TEX_FILTERING;
1054 static void quirk_r200_constants(struct wined3d_gl_info *gl_info)
1056 /* The Mesa r200 driver (and there is no other driver for this GPU Wine would run on)
1057 * loads some fog parameters (start, end, exponent, but not the color) into the
1058 * program.
1060 * Apparently the fog hardware is only able to handle linear fog with a range of 0.0;1.0,
1061 * and it is the responsibility of the vertex pipeline to handle non-linear fog and
1062 * linear fog with start and end other than 0.0 and 1.0. */
1063 TRACE("Reserving 1 ARB constant for compiler private use.\n");
1064 gl_info->reserved_arb_constants = max(gl_info->reserved_arb_constants, 1);
1067 static void quirk_broken_arb_fog(struct wined3d_gl_info *gl_info)
1069 gl_info->quirks |= WINED3D_QUIRK_BROKEN_ARB_FOG;
1072 static void quirk_broken_viewport_subpixel_bits(struct wined3d_gl_info *gl_info)
1074 if (gl_info->supported[ARB_CLIP_CONTROL])
1076 TRACE("Disabling ARB_clip_control.\n");
1077 gl_info->supported[ARB_CLIP_CONTROL] = FALSE;
1081 struct driver_quirk
1083 BOOL (*match)(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
1084 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
1085 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device);
1086 void (*apply)(struct wined3d_gl_info *gl_info);
1087 const char *description;
1090 static const struct driver_quirk quirk_table[] =
1093 match_amd_r300_to_500,
1094 quirk_amd_dx9,
1095 "AMD normalized texrect quirk"
1098 match_apple,
1099 quirk_apple_glsl_constants,
1100 "Apple GLSL uniform override"
1103 match_geforce5,
1104 quirk_no_np2,
1105 "Geforce 5 NP2 disable"
1108 match_apple_intel,
1109 quirk_texcoord_w,
1110 "Init texcoord .w for Apple Intel GPU driver"
1113 match_apple_nonr500ati,
1114 quirk_texcoord_w,
1115 "Init texcoord .w for Apple ATI >= r600 GPU driver"
1118 match_dx10_capable,
1119 quirk_clip_varying,
1120 "Reserved varying for gl_ClipPos"
1123 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
1124 * GL implementations accept it. The Mac GL is the only implementation known to
1125 * reject it.
1127 * If we can pass 4 component specular colors, do it, because (a) we don't have
1128 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
1129 * passes specular alpha to the pixel shader if any is used. Otherwise the
1130 * specular alpha is used to pass the fog coordinate, which we pass to opengl
1131 * via GL_EXT_fog_coord.
1133 match_allows_spec_alpha,
1134 quirk_allows_specular_alpha,
1135 "Allow specular alpha quirk"
1138 match_broken_nv_clip,
1139 quirk_disable_nvvp_clip,
1140 "Apple NV_vertex_program clip bug quirk"
1143 match_fbo_tex_update,
1144 quirk_fbo_tex_update,
1145 "FBO rebind for attachment updates"
1148 match_broken_rgba16,
1149 quirk_broken_rgba16,
1150 "True RGBA16 is not available"
1153 match_fglrx,
1154 quirk_infolog_spam,
1155 "Not printing GLSL infolog"
1158 match_not_dx10_capable,
1159 quirk_limited_tex_filtering,
1160 "Texture filtering, blending and VTF support is limited"
1163 match_r200,
1164 quirk_r200_constants,
1165 "r200 vertex shader constants"
1168 match_broken_arb_fog,
1169 quirk_broken_arb_fog,
1170 "ARBfp fogstart == fogend workaround"
1173 match_broken_viewport_subpixel_bits,
1174 quirk_broken_viewport_subpixel_bits,
1175 "Nvidia viewport subpixel bits bug"
1179 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
1180 * reporting a driver version is moot because we are not the Windows driver, and we have different
1181 * bugs, features, etc.
1183 * The driver version has the form "x.y.z.w".
1185 * "x" is the Windows version the driver is meant for:
1186 * 4 -> 95/98/NT4
1187 * 5 -> 2000
1188 * 6 -> 2000/XP
1189 * 7 -> Vista
1190 * 8 -> Win 7
1192 * "y" is the maximum Direct3D version the driver supports.
1193 * y -> d3d version mapping:
1194 * 11 -> d3d6
1195 * 12 -> d3d7
1196 * 13 -> d3d8
1197 * 14 -> d3d9
1198 * 15 -> d3d10
1199 * 16 -> d3d10.1
1200 * 17 -> d3d11
1202 * "z" is the subversion number.
1204 * "w" is the vendor specific driver build number.
1207 struct driver_version_information
1209 enum wined3d_display_driver driver;
1210 enum wined3d_driver_model driver_model;
1211 const char *driver_name; /* name of Windows driver */
1212 WORD version; /* version word ('y'), contained in low word of DriverVersion.HighPart */
1213 WORD subversion; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
1214 WORD build; /* build number ('w'), contained in low word of DriverVersion.LowPart */
1217 /* The driver version table contains driver information for different devices on several OS versions. */
1218 static const struct driver_version_information driver_version_table[] =
1220 /* AMD
1221 * - Radeon HD2x00 (R600) and up supported by current drivers.
1222 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
1223 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
1224 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
1225 {DRIVER_AMD_RAGE_128PRO, DRIVER_MODEL_NT5X, "ati2dvaa.dll", 13, 3279, 0},
1226 {DRIVER_AMD_R100, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6614},
1227 {DRIVER_AMD_R300, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6764},
1228 {DRIVER_AMD_R600, DRIVER_MODEL_NT5X, "ati2dvag.dll", 17, 10, 1280},
1229 {DRIVER_AMD_R300, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
1230 {DRIVER_AMD_R600, DRIVER_MODEL_NT6X, "atiumdag.dll", 17, 10, 1280},
1231 {DRIVER_AMD_RX, DRIVER_MODEL_NT6X, "aticfx32.dll", 17, 10, 1474},
1233 /* Intel
1234 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
1235 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
1236 * igxprd32.dll but the GMA800 driver was never updated. */
1237 {DRIVER_INTEL_GMA800, DRIVER_MODEL_NT5X, "ialmrnt5.dll", 14, 10, 3889},
1238 {DRIVER_INTEL_GMA900, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4764},
1239 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4926},
1240 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 5218},
1241 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT6X, "igdumd32.dll", 14, 10, 1504},
1242 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT6X, "igdumd32.dll", 15, 10, 1666},
1243 {DRIVER_INTEL_HD4000, DRIVER_MODEL_NT6X, "igdumdim32.dll", 19, 15, 4352},
1245 /* Nvidia
1246 * - Geforce8 and newer is supported by the current 340.52 driver on XP-Win8
1247 * - Geforce6 and 7 support is up to 307.83 on XP-Win8
1248 * - GeforceFX support is up to 173.x on <= XP
1249 * - Geforce2MX/3/4 up to 96.x on <= XP
1250 * - TNT/Geforce1/2 up to 71.x on <= XP
1251 * All version numbers used below are from the Linux nvidia drivers. */
1252 {DRIVER_NVIDIA_TNT, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 7186},
1253 {DRIVER_NVIDIA_GEFORCE2MX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 9371},
1254 {DRIVER_NVIDIA_GEFORCEFX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 11, 7516},
1255 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT5X, "nv4_disp.dll", 18, 13, 783},
1256 {DRIVER_NVIDIA_GEFORCE8, DRIVER_MODEL_NT5X, "nv4_disp.dll", 18, 13, 4052},
1257 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT6X, "nvd3dum.dll", 18, 13, 783},
1258 {DRIVER_NVIDIA_GEFORCE8, DRIVER_MODEL_NT6X, "nvd3dum.dll", 18, 13, 4052},
1260 /* VMware */
1261 {DRIVER_VMWARE, DRIVER_MODEL_NT5X, "vm3dum.dll", 14, 1, 1134},
1264 struct gpu_description
1266 WORD vendor; /* reported PCI card vendor ID */
1267 WORD card; /* reported PCI card device ID */
1268 const char *description; /* Description of the card e.g. NVIDIA RIVA TNT */
1269 enum wined3d_display_driver driver;
1270 unsigned int vidmem;
1273 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1274 * found on a board containing a specific GPU. */
1275 static const struct gpu_description gpu_description_table[] =
1277 /* Nvidia cards */
1278 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_128, "NVIDIA RIVA 128", DRIVER_NVIDIA_TNT, 4 },
1279 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT, 16 },
1280 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT, 32 },
1281 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT, 32 },
1282 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT, 32 },
1283 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX,32 },
1284 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX,64 },
1285 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX,64 },
1286 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX,64, },
1287 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX, 64 },
1288 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX, 128 },
1289 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX, 256 },
1290 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6, 64 },
1291 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6, 128 },
1292 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6, 128 },
1293 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6, 256 },
1294 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6, 256 },
1295 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1296 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1297 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8200, "NVIDIA GeForce 8200", DRIVER_NVIDIA_GEFORCE8, 512 },
1298 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE8, 128 },
1299 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8400GS, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE8, 128 },
1300 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8500GT, "NVIDIA GeForce 8500 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
1301 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
1302 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE8, 512 },
1303 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE8, 320 },
1304 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTX, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE8, 768 },
1305 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE8, 256 },
1306 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9300, "NVIDIA GeForce 9300", DRIVER_NVIDIA_GEFORCE8, 256 },
1307 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400M, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE8, 256 },
1308 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
1309 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
1310 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE8, 512 },
1311 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9700MGT, "NVIDIA GeForce 9700M GT", DRIVER_NVIDIA_GEFORCE8, 512 },
1312 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE8, 512 },
1313 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_210, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE8, 512 },
1314 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT220, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE8, 512 },
1315 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE8, 512 },
1316 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS250, "NVIDIA GeForce GTS 250", DRIVER_NVIDIA_GEFORCE8, 1024},
1317 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE8, 1024},
1318 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE8, 896 },
1319 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE8, 1024},
1320 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_315M, "NVIDIA GeForce 315M", DRIVER_NVIDIA_GEFORCE8, 512 },
1321 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_320M, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE8, 256},
1322 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT320M, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE8, 1024},
1323 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT325M, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE8, 1024},
1324 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT330, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE8, 1024},
1325 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS350M, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE8, 1024},
1326 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_410M, "NVIDIA GeForce 410M", DRIVER_NVIDIA_GEFORCE8, 512},
1327 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT420, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE8, 2048},
1328 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT425M, "NVIDIA GeForce GT 425M", DRIVER_NVIDIA_GEFORCE8, 1024},
1329 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT430, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE8, 1024},
1330 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT440, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE8, 1024},
1331 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS450, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE8, 1024},
1332 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE8, 768 },
1333 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460M, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_GEFORCE8, 1536},
1334 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX465, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE8, 1024},
1335 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX470, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE8, 1280},
1336 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX480, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE8, 1536},
1337 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT520, "NVIDIA GeForce GT 520", DRIVER_NVIDIA_GEFORCE8, 1024},
1338 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT525M, "NVIDIA GeForce GT 525M", DRIVER_NVIDIA_GEFORCE8, 1024},
1339 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT540M, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_GEFORCE8, 1024},
1340 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX550, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
1341 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT555M, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE8, 1024},
1342 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560TI, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
1343 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560M, "NVIDIA GeForce GTX 560M", DRIVER_NVIDIA_GEFORCE8, 3072},
1344 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE8, 1024},
1345 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX570, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE8, 1280},
1346 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX580, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE8, 1536},
1347 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT610, "NVIDIA GeForce GT 610", DRIVER_NVIDIA_GEFORCE8, 1024},
1348 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630, "NVIDIA GeForce GT 630", DRIVER_NVIDIA_GEFORCE8, 1024},
1349 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630M, "NVIDIA GeForce GT 630M", DRIVER_NVIDIA_GEFORCE8, 1024},
1350 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT640M, "NVIDIA GeForce GT 640M", DRIVER_NVIDIA_GEFORCE8, 1024},
1351 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT650M, "NVIDIA GeForce GT 650M", DRIVER_NVIDIA_GEFORCE8, 2048},
1352 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650, "NVIDIA GeForce GTX 650", DRIVER_NVIDIA_GEFORCE8, 1024},
1353 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650TI, "NVIDIA GeForce GTX 650 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
1354 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660, "NVIDIA GeForce GTX 660", DRIVER_NVIDIA_GEFORCE8, 2048},
1355 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660M, "NVIDIA GeForce GTX 660M", DRIVER_NVIDIA_GEFORCE8, 2048},
1356 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660TI, "NVIDIA GeForce GTX 660 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
1357 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_GEFORCE8, 2048},
1358 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670MX, "NVIDIA GeForce GTX 670MX", DRIVER_NVIDIA_GEFORCE8, 3072},
1359 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX675MX, "NVIDIA GeForce GTX 675MX", DRIVER_NVIDIA_GEFORCE8, 4096},
1360 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX680, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_GEFORCE8, 2048},
1361 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX690, "NVIDIA GeForce GTX 690", DRIVER_NVIDIA_GEFORCE8, 2048},
1362 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT730, "NVIDIA GeForce GT 730", DRIVER_NVIDIA_GEFORCE8, 2048},
1363 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT730M, "NVIDIA GeForce GT 730M", DRIVER_NVIDIA_GEFORCE8, 1024},
1364 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT740M, "NVIDIA GeForce GT 740M", DRIVER_NVIDIA_GEFORCE8, 2048},
1365 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT750M, "NVIDIA GeForce GT 750M", DRIVER_NVIDIA_GEFORCE8, 1024},
1366 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX750, "NVIDIA GeForce GTX 750", DRIVER_NVIDIA_GEFORCE8, 1024},
1367 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX750TI, "NVIDIA GeForce GTX 750 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
1368 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX760, "NVIDIA GeForce GTX 760", DRIVER_NVIDIA_GEFORCE8, 2048},
1369 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX760TI, "NVIDIA GeForce GTX 760 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
1370 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX765M, "NVIDIA GeForce GTX 765M", DRIVER_NVIDIA_GEFORCE8, 2048},
1371 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770M, "NVIDIA GeForce GTX 770M", DRIVER_NVIDIA_GEFORCE8, 3072},
1372 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770, "NVIDIA GeForce GTX 770", DRIVER_NVIDIA_GEFORCE8, 2048},
1373 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780, "NVIDIA GeForce GTX 780", DRIVER_NVIDIA_GEFORCE8, 3072},
1374 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780TI, "NVIDIA GeForce GTX 780 Ti", DRIVER_NVIDIA_GEFORCE8, 3072},
1375 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITAN, "NVIDIA GeForce GTX TITAN", DRIVER_NVIDIA_GEFORCE8, 6144},
1376 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANB, "NVIDIA GeForce GTX TITAN Black", DRIVER_NVIDIA_GEFORCE8, 6144},
1377 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANX, "NVIDIA GeForce GTX TITAN X", DRIVER_NVIDIA_GEFORCE8, 12288},
1378 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANZ, "NVIDIA GeForce GTX TITAN Z", DRIVER_NVIDIA_GEFORCE8, 12288},
1379 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_820M, "NVIDIA GeForce 820M", DRIVER_NVIDIA_GEFORCE8, 2048},
1380 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_830M, "NVIDIA GeForce 830M", DRIVER_NVIDIA_GEFORCE8, 2048},
1381 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_840M, "NVIDIA GeForce 840M", DRIVER_NVIDIA_GEFORCE8, 2048},
1382 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_845M, "NVIDIA GeForce 845M", DRIVER_NVIDIA_GEFORCE8, 2048},
1383 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX850M, "NVIDIA GeForce GTX 850M", DRIVER_NVIDIA_GEFORCE8, 2048},
1384 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX860M, "NVIDIA GeForce GTX 860M", DRIVER_NVIDIA_GEFORCE8, 2048},
1385 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX870M, "NVIDIA GeForce GTX 870M", DRIVER_NVIDIA_GEFORCE8, 3072},
1386 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX880M, "NVIDIA GeForce GTX 880M", DRIVER_NVIDIA_GEFORCE8, 4096},
1387 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_940M, "NVIDIA GeForce 940M", DRIVER_NVIDIA_GEFORCE8, 4096},
1388 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX950, "NVIDIA GeForce GTX 950", DRIVER_NVIDIA_GEFORCE8, 2048},
1389 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX950M, "NVIDIA GeForce GTX 950M", DRIVER_NVIDIA_GEFORCE8, 4096},
1390 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX960, "NVIDIA GeForce GTX 960", DRIVER_NVIDIA_GEFORCE8, 4096},
1391 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX960M, "NVIDIA GeForce GTX 960M", DRIVER_NVIDIA_GEFORCE8, 2048},
1392 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX970, "NVIDIA GeForce GTX 970", DRIVER_NVIDIA_GEFORCE8, 4096},
1393 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX970M, "NVIDIA GeForce GTX 970M", DRIVER_NVIDIA_GEFORCE8, 3072},
1394 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX980, "NVIDIA GeForce GTX 980", DRIVER_NVIDIA_GEFORCE8, 4096},
1395 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX980TI, "NVIDIA GeForce GTX 980 Ti", DRIVER_NVIDIA_GEFORCE8, 6144},
1396 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1050, "NVIDIA GeForce GTX 1050", DRIVER_NVIDIA_GEFORCE8, 2048},
1397 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1050TI, "NVIDIA GeForce GTX 1050 Ti", DRIVER_NVIDIA_GEFORCE8, 4096},
1398 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1060, "NVIDIA GeForce GTX 1060", DRIVER_NVIDIA_GEFORCE8, 6144},
1399 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1070, "NVIDIA GeForce GTX 1070", DRIVER_NVIDIA_GEFORCE8, 8192},
1400 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1080, "NVIDIA GeForce GTX 1080", DRIVER_NVIDIA_GEFORCE8, 8192},
1401 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1080TI, "NVIDIA GeForce GTX 1080 Ti", DRIVER_NVIDIA_GEFORCE8, 11264},
1402 {HW_VENDOR_NVIDIA, CARD_NVIDIA_TITANX_PASCAL, "NVIDIA TITAN X (Pascal)", DRIVER_NVIDIA_GEFORCE8, 12288},
1404 /* AMD cards */
1405 {HW_VENDOR_AMD, CARD_AMD_RAGE_128PRO, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO, 16 },
1406 {HW_VENDOR_AMD, CARD_AMD_RADEON_7200, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100, 32 },
1407 {HW_VENDOR_AMD, CARD_AMD_RADEON_8500, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100, 64 },
1408 {HW_VENDOR_AMD, CARD_AMD_RADEON_9500, "ATI Radeon 9500", DRIVER_AMD_R300, 64 },
1409 {HW_VENDOR_AMD, CARD_AMD_RADEON_XPRESS_200M, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300, 64 },
1410 {HW_VENDOR_AMD, CARD_AMD_RADEON_X700, "ATI Radeon X700 SE", DRIVER_AMD_R300, 128 },
1411 {HW_VENDOR_AMD, CARD_AMD_RADEON_X1600, "ATI Radeon X1600 Series", DRIVER_AMD_R300, 128 },
1412 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2350, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600, 256 },
1413 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2600, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600, 256 },
1414 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2900, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600, 512 },
1415 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3200, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600, 128 },
1416 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3850, "ATI Radeon HD 3850 AGP", DRIVER_AMD_R600, 512 },
1417 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4200M, "ATI Mobility Radeon HD 4200", DRIVER_AMD_R600, 256 },
1418 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4350, "ATI Radeon HD 4350", DRIVER_AMD_R600, 256 },
1419 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4600, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600, 512 },
1420 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4700, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600, 512 },
1421 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4800, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600, 512 },
1422 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5400, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600, 512 },
1423 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5600, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600, 512 },
1424 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5700, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600, 512 },
1425 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5800, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600, 1024},
1426 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5900, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600, 1024},
1427 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6300, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600, 1024},
1428 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6400, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600, 1024},
1429 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6410D, "AMD Radeon HD 6410D", DRIVER_AMD_R600, 1024},
1430 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6480G, "AMD Radeon HD 6480G", DRIVER_AMD_R600, 512 },
1431 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6550D, "AMD Radeon HD 6550D", DRIVER_AMD_R600, 1024},
1432 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600, 1024},
1433 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600M, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600, 512 },
1434 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6700, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600, 1024},
1435 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6800, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600, 1024},
1436 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6900, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600, 2048},
1437 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7660D, "AMD Radeon HD 7660D", DRIVER_AMD_R600, 2048},
1438 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7700, "AMD Radeon HD 7700 Series", DRIVER_AMD_R600, 1024},
1439 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7800, "AMD Radeon HD 7800 Series", DRIVER_AMD_R600, 2048},
1440 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7900, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600, 2048},
1441 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8600M, "AMD Radeon HD 8600M Series", DRIVER_AMD_R600, 1024},
1442 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8670, "AMD Radeon HD 8670", DRIVER_AMD_R600, 2048},
1443 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8770, "AMD Radeon HD 8770", DRIVER_AMD_R600, 2048},
1444 {HW_VENDOR_AMD, CARD_AMD_RADEON_R3, "AMD Radeon HD 8400 / R3 Series", DRIVER_AMD_R600, 2048},
1445 {HW_VENDOR_AMD, CARD_AMD_RADEON_R7, "AMD Radeon(TM) R7 Graphics", DRIVER_AMD_R600, 2048},
1446 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_285, "AMD Radeon R9 285", DRIVER_AMD_RX, 2048},
1447 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_290, "AMD Radeon R9 290", DRIVER_AMD_RX, 4096},
1448 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_FURY, "AMD Radeon (TM) R9 Fury Series", DRIVER_AMD_RX, 4096},
1449 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_460, "Radeon(TM) RX 460 Graphics", DRIVER_AMD_RX, 4096},
1450 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_480, "Radeon (TM) RX 480 Graphics", DRIVER_AMD_RX, 4096},
1452 /* VMware */
1453 {HW_VENDOR_VMWARE, CARD_VMWARE_SVGA3D, "VMware SVGA 3D (Microsoft Corporation - WDDM)", DRIVER_VMWARE, 1024},
1455 /* Intel cards */
1456 {HW_VENDOR_INTEL, CARD_INTEL_830M, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1457 {HW_VENDOR_INTEL, CARD_INTEL_855GM, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1458 {HW_VENDOR_INTEL, CARD_INTEL_845G, "Intel(R) 845G", DRIVER_INTEL_GMA800, 32 },
1459 {HW_VENDOR_INTEL, CARD_INTEL_865G, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1460 {HW_VENDOR_INTEL, CARD_INTEL_915G, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
1461 {HW_VENDOR_INTEL, CARD_INTEL_E7221G, "Intel(R) E7221G", DRIVER_INTEL_GMA900, 64 },
1462 {HW_VENDOR_INTEL, CARD_INTEL_915GM, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
1463 {HW_VENDOR_INTEL, CARD_INTEL_945G, "Intel(R) 945G", DRIVER_INTEL_GMA950, 64 },
1464 {HW_VENDOR_INTEL, CARD_INTEL_945GM, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950, 64 },
1465 {HW_VENDOR_INTEL, CARD_INTEL_945GME, "Intel(R) 945GME", DRIVER_INTEL_GMA950, 64 },
1466 {HW_VENDOR_INTEL, CARD_INTEL_Q35, "Intel(R) Q35", DRIVER_INTEL_GMA950, 64 },
1467 {HW_VENDOR_INTEL, CARD_INTEL_G33, "Intel(R) G33", DRIVER_INTEL_GMA950, 64 },
1468 {HW_VENDOR_INTEL, CARD_INTEL_Q33, "Intel(R) Q33", DRIVER_INTEL_GMA950, 64 },
1469 {HW_VENDOR_INTEL, CARD_INTEL_PNVG, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
1470 {HW_VENDOR_INTEL, CARD_INTEL_PNVM, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
1471 {HW_VENDOR_INTEL, CARD_INTEL_965Q, "Intel(R) 965Q", DRIVER_INTEL_GMA3000, 128},
1472 {HW_VENDOR_INTEL, CARD_INTEL_965G, "Intel(R) 965G", DRIVER_INTEL_GMA3000, 128},
1473 {HW_VENDOR_INTEL, CARD_INTEL_946GZ, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000, 128},
1474 {HW_VENDOR_INTEL, CARD_INTEL_965GM, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000, 128},
1475 {HW_VENDOR_INTEL, CARD_INTEL_965GME, "Intel(R) 965GME", DRIVER_INTEL_GMA3000, 128},
1476 {HW_VENDOR_INTEL, CARD_INTEL_GM45, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000, 512},
1477 {HW_VENDOR_INTEL, CARD_INTEL_IGD, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000, 512},
1478 {HW_VENDOR_INTEL, CARD_INTEL_G45, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000, 512},
1479 {HW_VENDOR_INTEL, CARD_INTEL_Q45, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000, 512},
1480 {HW_VENDOR_INTEL, CARD_INTEL_G41, "Intel(R) G41", DRIVER_INTEL_GMA3000, 512},
1481 {HW_VENDOR_INTEL, CARD_INTEL_B43, "Intel(R) B43", DRIVER_INTEL_GMA3000, 512},
1482 {HW_VENDOR_INTEL, CARD_INTEL_ILKD, "Intel(R) HD Graphics", DRIVER_INTEL_GMA3000, 1536},
1483 {HW_VENDOR_INTEL, CARD_INTEL_ILKM, "Intel(R) HD Graphics", DRIVER_INTEL_GMA3000, 1536},
1484 {HW_VENDOR_INTEL, CARD_INTEL_SNBD, "Intel(R) HD Graphics 3000", DRIVER_INTEL_GMA3000, 1536},
1485 {HW_VENDOR_INTEL, CARD_INTEL_SNBM, "Intel(R) HD Graphics 3000", DRIVER_INTEL_GMA3000, 1536},
1486 {HW_VENDOR_INTEL, CARD_INTEL_SNBS, "Intel(R) HD Graphics Family", DRIVER_INTEL_GMA3000, 1536},
1487 {HW_VENDOR_INTEL, CARD_INTEL_IVBD, "Intel(R) HD Graphics 4000", DRIVER_INTEL_HD4000, 1536},
1488 {HW_VENDOR_INTEL, CARD_INTEL_IVBM, "Intel(R) HD Graphics 4000", DRIVER_INTEL_HD4000, 1536},
1489 {HW_VENDOR_INTEL, CARD_INTEL_IVBS, "Intel(R) HD Graphics Family", DRIVER_INTEL_HD4000, 1536},
1490 {HW_VENDOR_INTEL, CARD_INTEL_HWD, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536},
1491 {HW_VENDOR_INTEL, CARD_INTEL_HWM, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536},
1492 {HW_VENDOR_INTEL, CARD_INTEL_HD5000, "Intel(R) HD Graphics 5000", DRIVER_INTEL_HD4000, 1536},
1493 {HW_VENDOR_INTEL, CARD_INTEL_I5100_1, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
1494 {HW_VENDOR_INTEL, CARD_INTEL_I5100_2, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
1495 {HW_VENDOR_INTEL, CARD_INTEL_I5100_3, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
1496 {HW_VENDOR_INTEL, CARD_INTEL_I5100_4, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
1497 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_1, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1498 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_2, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1499 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_3, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1500 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_4, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1501 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_5, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1502 {HW_VENDOR_INTEL, CARD_INTEL_HD5300, "Intel(R) HD Graphics 5300", DRIVER_INTEL_HD4000, 2048},
1503 {HW_VENDOR_INTEL, CARD_INTEL_HD5500, "Intel(R) HD Graphics 5500", DRIVER_INTEL_HD4000, 2048},
1504 {HW_VENDOR_INTEL, CARD_INTEL_HD5600, "Intel(R) HD Graphics 5600", DRIVER_INTEL_HD4000, 2048},
1505 {HW_VENDOR_INTEL, CARD_INTEL_HD6000, "Intel(R) HD Graphics 6000", DRIVER_INTEL_HD4000, 2048},
1506 {HW_VENDOR_INTEL, CARD_INTEL_I6100, "Intel(R) Iris(TM) Graphics 6100", DRIVER_INTEL_HD4000, 2048},
1507 {HW_VENDOR_INTEL, CARD_INTEL_IP6200, "Intel(R) Iris(TM) Pro Graphics 6200", DRIVER_INTEL_HD4000, 2048},
1508 {HW_VENDOR_INTEL, CARD_INTEL_IPP6300, "Intel(R) Iris(TM) Pro Graphics P6300", DRIVER_INTEL_HD4000, 2048},
1509 {HW_VENDOR_INTEL, CARD_INTEL_HD510_1, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
1510 {HW_VENDOR_INTEL, CARD_INTEL_HD510_2, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
1511 {HW_VENDOR_INTEL, CARD_INTEL_HD510_3, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
1512 {HW_VENDOR_INTEL, CARD_INTEL_HD515, "Intel(R) HD Graphics 515", DRIVER_INTEL_HD4000, 2048},
1513 {HW_VENDOR_INTEL, CARD_INTEL_HD520_1, "Intel(R) HD Graphics 520", DRIVER_INTEL_HD4000, 2048},
1514 {HW_VENDOR_INTEL, CARD_INTEL_HD520_2, "Intel(R) HD Graphics 520", DRIVER_INTEL_HD4000, 2048},
1515 {HW_VENDOR_INTEL, CARD_INTEL_HD530_1, "Intel(R) HD Graphics 530", DRIVER_INTEL_HD4000, 2048},
1516 {HW_VENDOR_INTEL, CARD_INTEL_HD530_2, "Intel(R) HD Graphics 530", DRIVER_INTEL_HD4000, 2048},
1517 {HW_VENDOR_INTEL, CARD_INTEL_HDP530, "Intel(R) HD Graphics P530", DRIVER_INTEL_HD4000, 2048},
1518 {HW_VENDOR_INTEL, CARD_INTEL_I540, "Intel(R) Iris(TM) Graphics 540", DRIVER_INTEL_HD4000, 2048},
1519 {HW_VENDOR_INTEL, CARD_INTEL_I550, "Intel(R) Iris(TM) Graphics 550", DRIVER_INTEL_HD4000, 2048},
1520 {HW_VENDOR_INTEL, CARD_INTEL_I555, "Intel(R) Iris(TM) Graphics 555", DRIVER_INTEL_HD4000, 2048},
1521 {HW_VENDOR_INTEL, CARD_INTEL_IP555, "Intel(R) Iris(TM) Graphics P555", DRIVER_INTEL_HD4000, 2048},
1522 {HW_VENDOR_INTEL, CARD_INTEL_IP580_1, "Intel(R) Iris(TM) Pro Graphics 580", DRIVER_INTEL_HD4000, 2048},
1523 {HW_VENDOR_INTEL, CARD_INTEL_IP580_2, "Intel(R) Iris(TM) Pro Graphics 580", DRIVER_INTEL_HD4000, 2048},
1524 {HW_VENDOR_INTEL, CARD_INTEL_IPP580_1, "Intel(R) Iris(TM) Pro Graphics P580", DRIVER_INTEL_HD4000, 2048},
1525 {HW_VENDOR_INTEL, CARD_INTEL_IPP580_2, "Intel(R) Iris(TM) Pro Graphics P580", DRIVER_INTEL_HD4000, 2048},
1528 static const struct driver_version_information *get_driver_version_info(enum wined3d_display_driver driver,
1529 enum wined3d_driver_model driver_model)
1531 unsigned int i;
1533 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver, driver_model);
1534 for (i = 0; i < ARRAY_SIZE(driver_version_table); ++i)
1536 const struct driver_version_information *entry = &driver_version_table[i];
1538 if (entry->driver == driver && (driver_model == DRIVER_MODEL_GENERIC
1539 || entry->driver_model == driver_model))
1541 TRACE("Found driver \"%s\", version %u, subversion %u, build %u.\n",
1542 entry->driver_name, entry->version, entry->subversion, entry->build);
1543 return entry;
1546 return NULL;
1549 static const struct gpu_description *get_gpu_description(enum wined3d_pci_vendor vendor,
1550 enum wined3d_pci_device device)
1552 unsigned int i;
1554 for (i = 0; i < ARRAY_SIZE(gpu_description_table); ++i)
1556 if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].card)
1557 return &gpu_description_table[i];
1560 return NULL;
1563 static const struct gpu_description *query_gpu_description(const struct wined3d_gl_info *gl_info, UINT64 *vram_bytes)
1565 enum wined3d_pci_vendor vendor = PCI_VENDOR_NONE;
1566 enum wined3d_pci_device device = PCI_DEVICE_NONE;
1567 const struct gpu_description *gpu_description;
1568 static unsigned int once;
1570 if (gl_info->supported[WGL_WINE_QUERY_RENDERER])
1572 GLuint value;
1574 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_VENDOR_ID_WINE, &value)))
1575 vendor = value;
1576 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_DEVICE_ID_WINE, &value)))
1577 device = value;
1578 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_VIDEO_MEMORY_WINE, &value)))
1579 *vram_bytes = (UINT64)value * 1024 * 1024;
1580 TRACE("Card reports vendor PCI ID 0x%04x, device PCI ID 0x%04x, 0x%s bytes of video memory.\n",
1581 vendor, device, wine_dbgstr_longlong(*vram_bytes));
1584 if (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
1586 vendor = wined3d_settings.pci_vendor_id;
1587 TRACE("Overriding vendor PCI ID with 0x%04x.\n", vendor);
1590 if (wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
1592 device = wined3d_settings.pci_device_id;
1593 TRACE("Overriding device PCI ID with 0x%04x.\n", device);
1596 if (wined3d_settings.emulated_textureram)
1598 *vram_bytes = wined3d_settings.emulated_textureram;
1599 TRACE("Overriding amount of video memory with 0x%s bytes.\n",
1600 wine_dbgstr_longlong(*vram_bytes));
1603 if (!(gpu_description = get_gpu_description(vendor, device))
1604 && (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE
1605 || wined3d_settings.pci_device_id != PCI_DEVICE_NONE) && !once++)
1606 ERR_(winediag)("Invalid GPU override %04x:%04x specified, ignoring.\n", vendor, device);
1608 return gpu_description;
1611 static void init_driver_info(struct wined3d_driver_info *driver_info,
1612 const struct gpu_description *gpu_desc, UINT64 vram_bytes)
1614 OSVERSIONINFOW os_version;
1615 WORD driver_os_version;
1616 enum wined3d_display_driver driver;
1617 enum wined3d_driver_model driver_model;
1618 const struct driver_version_information *version_info;
1620 memset(&os_version, 0, sizeof(os_version));
1621 os_version.dwOSVersionInfoSize = sizeof(os_version);
1622 if (!GetVersionExW(&os_version))
1624 ERR("Failed to get OS version, reporting 2000/XP.\n");
1625 driver_os_version = 6;
1626 driver_model = DRIVER_MODEL_NT5X;
1628 else
1630 TRACE("OS version %u.%u.\n", os_version.dwMajorVersion, os_version.dwMinorVersion);
1631 switch (os_version.dwMajorVersion)
1633 case 4:
1634 /* If needed we could distinguish between 9x and NT4, but this code won't make
1635 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1637 driver_os_version = 4;
1638 driver_model = DRIVER_MODEL_WIN9X;
1639 break;
1641 case 5:
1642 driver_os_version = 6;
1643 driver_model = DRIVER_MODEL_NT5X;
1644 break;
1646 case 6:
1647 if (os_version.dwMinorVersion == 0)
1649 driver_os_version = 7;
1650 driver_model = DRIVER_MODEL_NT6X;
1652 else if (os_version.dwMinorVersion == 1)
1654 driver_os_version = 8;
1655 driver_model = DRIVER_MODEL_NT6X;
1657 else
1659 if (os_version.dwMinorVersion > 2)
1661 FIXME("Unhandled OS version %u.%u, reporting Win 8.\n",
1662 os_version.dwMajorVersion, os_version.dwMinorVersion);
1664 driver_os_version = 9;
1665 driver_model = DRIVER_MODEL_NT6X;
1667 break;
1669 case 10:
1670 driver_os_version = 10;
1671 driver_model = DRIVER_MODEL_NT6X;
1672 break;
1674 default:
1675 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1676 os_version.dwMajorVersion, os_version.dwMinorVersion);
1677 driver_os_version = 6;
1678 driver_model = DRIVER_MODEL_NT5X;
1679 break;
1683 driver_info->vendor = gpu_desc->vendor;
1684 driver_info->device = gpu_desc->card;
1685 driver_info->description = gpu_desc->description;
1686 driver_info->vram_bytes = vram_bytes ? vram_bytes : (UINT64)gpu_desc->vidmem * 1024 * 1024;
1687 driver = gpu_desc->driver;
1690 * Diablo 2 crashes when the amount of video memory is greater than 0x7fffffff.
1691 * In order to avoid this application bug we limit the amount of video memory
1692 * to LONG_MAX for older Windows versions.
1694 if (driver_model < DRIVER_MODEL_NT6X && driver_info->vram_bytes > LONG_MAX)
1696 TRACE("Limiting amount of video memory to %#lx bytes for OS version older than Vista.\n", LONG_MAX);
1697 driver_info->vram_bytes = LONG_MAX;
1700 /* Try to obtain driver version information for the current Windows version. This fails in
1701 * some cases:
1702 * - the gpu is not available on the currently selected OS version:
1703 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1704 * version information for the current Windows version is returned instead of faked info.
1705 * We do the same and assume the default Windows version to emulate is WinXP.
1707 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1708 * For now return the XP driver info. Perhaps later on we should return VESA.
1710 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1711 * This could be an indication that our database is not up to date, so this should be fixed.
1713 if ((version_info = get_driver_version_info(driver, driver_model))
1714 || (version_info = get_driver_version_info(driver, DRIVER_MODEL_GENERIC)))
1716 driver_info->name = version_info->driver_name;
1717 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version);
1718 driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
1720 else
1722 ERR("No driver version info found for device %04x:%04x, driver model %#x.\n",
1723 driver_info->vendor, driver_info->device, driver_model);
1724 driver_info->name = "Display";
1725 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, 15);
1726 driver_info->version_low = MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1729 TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1730 driver_info->version_high, driver_info->version_low);
1733 /* Context activation is done by the caller. */
1734 static void fixup_extensions(struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
1735 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
1736 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
1738 unsigned int i;
1740 for (i = 0; i < ARRAY_SIZE(quirk_table); ++i)
1742 if (!quirk_table[i].match(gl_info, ctx, gl_renderer, gl_vendor, card_vendor, device)) continue;
1743 TRACE("Applying driver quirk \"%s\".\n", quirk_table[i].description);
1744 quirk_table[i].apply(gl_info);
1747 /* Find out if PBOs work as they are supposed to. */
1748 test_pbo_functionality(gl_info);
1751 static DWORD wined3d_parse_gl_version(const char *gl_version)
1753 const char *ptr = gl_version;
1754 int major, minor;
1756 major = atoi(ptr);
1757 if (major <= 0)
1758 ERR("Invalid OpenGL major version %d.\n", major);
1760 while (isdigit(*ptr)) ++ptr;
1761 if (*ptr++ != '.')
1762 ERR("Invalid OpenGL version string %s.\n", debugstr_a(gl_version));
1764 minor = atoi(ptr);
1766 TRACE("Found OpenGL version %d.%d.\n", major, minor);
1768 return MAKEDWORD_VERSION(major, minor);
1771 static enum wined3d_gl_vendor wined3d_guess_gl_vendor(const struct wined3d_gl_info *gl_info,
1772 const char *gl_vendor_string, const char *gl_renderer, const char *gl_version)
1774 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1775 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1776 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1778 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1779 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1780 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1781 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1782 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1783 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1784 * DirectDraw, not OpenGL. */
1785 if (gl_info->supported[APPLE_FENCE] && gl_info->supported[APPLE_YCBCR_422])
1786 return GL_VENDOR_APPLE;
1788 if (strstr(gl_vendor_string, "NVIDIA"))
1789 return GL_VENDOR_NVIDIA;
1791 if (strstr(gl_vendor_string, "ATI"))
1792 return GL_VENDOR_FGLRX;
1794 if (strstr(gl_vendor_string, "Mesa")
1795 || strstr(gl_vendor_string, "X.Org")
1796 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1797 || strstr(gl_vendor_string, "DRI R300 Project")
1798 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1799 || strstr(gl_vendor_string, "VMware, Inc.")
1800 || strstr(gl_vendor_string, "Intel")
1801 || strstr(gl_renderer, "Mesa")
1802 || strstr(gl_renderer, "Gallium")
1803 || strstr(gl_renderer, "Intel")
1804 || strstr(gl_version, "Mesa"))
1805 return GL_VENDOR_MESA;
1807 FIXME("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1808 debugstr_a(gl_vendor_string));
1810 return GL_VENDOR_UNKNOWN;
1813 static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer)
1815 if (strstr(gl_vendor_string, "NVIDIA")
1816 || strstr(gl_vendor_string, "Nouveau")
1817 || strstr(gl_vendor_string, "nouveau"))
1818 return HW_VENDOR_NVIDIA;
1820 if (strstr(gl_vendor_string, "ATI")
1821 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1822 || strstr(gl_vendor_string, "X.Org R300 Project")
1823 || strstr(gl_renderer, "AMD")
1824 || strstr(gl_renderer, "FirePro")
1825 || strstr(gl_renderer, "Radeon")
1826 || strstr(gl_renderer, "R100")
1827 || strstr(gl_renderer, "R200")
1828 || strstr(gl_renderer, "R300")
1829 || strstr(gl_renderer, "R600")
1830 || strstr(gl_renderer, "R700"))
1831 return HW_VENDOR_AMD;
1833 if (strstr(gl_vendor_string, "Intel(R)")
1834 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1835 || strstr(gl_renderer, "Intel")
1836 || strstr(gl_renderer, "i915")
1837 || strstr(gl_vendor_string, "Intel Inc."))
1838 return HW_VENDOR_INTEL;
1840 if (strstr(gl_renderer, "SVGA3D"))
1841 return HW_VENDOR_VMWARE;
1843 if (strstr(gl_vendor_string, "Mesa")
1844 || strstr(gl_vendor_string, "Brian Paul")
1845 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1846 || strstr(gl_vendor_string, "VMware, Inc."))
1847 return HW_VENDOR_SOFTWARE;
1849 FIXME("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string));
1851 return HW_VENDOR_NVIDIA;
1854 static enum wined3d_d3d_level d3d_level_from_caps(const struct shader_caps *shader_caps, const struct fragment_caps *fragment_caps, DWORD glsl_version)
1856 if (shader_caps->vs_version >= 5)
1857 return WINED3D_D3D_LEVEL_11;
1858 if (shader_caps->vs_version == 4)
1859 return WINED3D_D3D_LEVEL_10;
1860 if (shader_caps->vs_version == 3)
1862 /* wined3d with default settings at the moment doesn't expose SM4+ on
1863 * Mesa drivers. */
1864 if (glsl_version >= MAKEDWORD_VERSION(4, 30))
1865 return WINED3D_D3D_LEVEL_11;
1866 if (glsl_version >= MAKEDWORD_VERSION(1, 30))
1867 return WINED3D_D3D_LEVEL_10;
1868 return WINED3D_D3D_LEVEL_9_SM3;
1870 if (shader_caps->vs_version == 2)
1871 return WINED3D_D3D_LEVEL_9_SM2;
1872 if (shader_caps->vs_version == 1)
1873 return WINED3D_D3D_LEVEL_8;
1875 if (fragment_caps->TextureOpCaps & WINED3DTEXOPCAPS_DOTPRODUCT3)
1876 return WINED3D_D3D_LEVEL_7;
1877 if (fragment_caps->MaxSimultaneousTextures > 1)
1878 return WINED3D_D3D_LEVEL_6;
1880 return WINED3D_D3D_LEVEL_5;
1883 static const struct wined3d_renderer_table
1885 const char *renderer;
1886 enum wined3d_pci_device id;
1888 cards_nvidia_binary[] =
1890 /* Direct 3D 11 */
1891 {"TITAN X (Pascal)", CARD_NVIDIA_TITANX_PASCAL}, /* GeForce 1000 - highend */
1892 {"GTX 1080 Ti", CARD_NVIDIA_GEFORCE_GTX1080TI}, /* GeForce 1000 - highend */
1893 {"GTX 1080", CARD_NVIDIA_GEFORCE_GTX1080}, /* GeForce 1000 - highend */
1894 {"GTX 1070", CARD_NVIDIA_GEFORCE_GTX1070}, /* GeForce 1000 - highend */
1895 {"GTX 1060", CARD_NVIDIA_GEFORCE_GTX1060}, /* GeForce 1000 - midend high */
1896 {"GTX 1050 Ti", CARD_NVIDIA_GEFORCE_GTX1050TI}, /* GeForce 1000 - midend */
1897 {"GTX 1050", CARD_NVIDIA_GEFORCE_GTX1050}, /* GeForce 1000 - midend */
1898 {"GTX 980 Ti", CARD_NVIDIA_GEFORCE_GTX980TI}, /* GeForce 900 - highend */
1899 {"GTX 980", CARD_NVIDIA_GEFORCE_GTX980}, /* GeForce 900 - highend */
1900 {"GTX 970M", CARD_NVIDIA_GEFORCE_GTX970M}, /* GeForce 900 - highend mobile*/
1901 {"GTX 970", CARD_NVIDIA_GEFORCE_GTX970}, /* GeForce 900 - highend */
1902 {"GTX TITAN X", CARD_NVIDIA_GEFORCE_GTXTITANX}, /* Geforce 900 - highend */
1903 {"GTX 960M", CARD_NVIDIA_GEFORCE_GTX960M}, /* GeForce 900 - midend high mobile */
1904 {"GTX 960", CARD_NVIDIA_GEFORCE_GTX960}, /* GeForce 900 - midend high */
1905 {"GTX 950M", CARD_NVIDIA_GEFORCE_GTX950M}, /* GeForce 900 - midend mobile */
1906 {"GTX 950", CARD_NVIDIA_GEFORCE_GTX950}, /* GeForce 900 - midend */
1907 {"GeForce 940M", CARD_NVIDIA_GEFORCE_940M}, /* GeForce 900 - midend mobile */
1908 {"GTX 880M", CARD_NVIDIA_GEFORCE_GTX880M}, /* GeForce 800 - mobile */
1909 {"GTX 870M", CARD_NVIDIA_GEFORCE_GTX870M}, /* GeForce 800 - mobile */
1910 {"GTX 860M", CARD_NVIDIA_GEFORCE_GTX860M}, /* GeForce 800 - mobile */
1911 {"GTX 850M", CARD_NVIDIA_GEFORCE_GTX850M}, /* GeForce 800 - mobile */
1912 {"GeForce 845M", CARD_NVIDIA_GEFORCE_845M}, /* GeForce 800 - mobile */
1913 {"GeForce 840M", CARD_NVIDIA_GEFORCE_840M}, /* GeForce 800 - mobile */
1914 {"GeForce 830M", CARD_NVIDIA_GEFORCE_830M}, /* GeForce 800 - mobile */
1915 {"GeForce 820M", CARD_NVIDIA_GEFORCE_820M}, /* GeForce 800 - mobile */
1916 {"GTX 780 Ti", CARD_NVIDIA_GEFORCE_GTX780TI}, /* Geforce 700 - highend */
1917 {"GTX TITAN Black", CARD_NVIDIA_GEFORCE_GTXTITANB}, /* Geforce 700 - highend */
1918 {"GTX TITAN Z", CARD_NVIDIA_GEFORCE_GTXTITANZ}, /* Geforce 700 - highend */
1919 {"GTX TITAN", CARD_NVIDIA_GEFORCE_GTXTITAN}, /* Geforce 700 - highend */
1920 {"GTX 780", CARD_NVIDIA_GEFORCE_GTX780}, /* Geforce 700 - highend */
1921 {"GTX 770M", CARD_NVIDIA_GEFORCE_GTX770M}, /* Geforce 700 - midend high mobile */
1922 {"GTX 770", CARD_NVIDIA_GEFORCE_GTX770}, /* Geforce 700 - highend */
1923 {"GTX 765M", CARD_NVIDIA_GEFORCE_GTX765M}, /* Geforce 700 - midend high mobile */
1924 {"GTX 760 Ti", CARD_NVIDIA_GEFORCE_GTX760TI}, /* Geforce 700 - midend high */
1925 {"GTX 760", CARD_NVIDIA_GEFORCE_GTX760}, /* Geforce 700 - midend high */
1926 {"GTX 750 Ti", CARD_NVIDIA_GEFORCE_GTX750TI}, /* Geforce 700 - midend */
1927 {"GTX 750", CARD_NVIDIA_GEFORCE_GTX750}, /* Geforce 700 - midend */
1928 {"GT 750M", CARD_NVIDIA_GEFORCE_GT750M}, /* Geforce 700 - midend mobile */
1929 {"GT 740M", CARD_NVIDIA_GEFORCE_GT740M}, /* Geforce 700 - midend mobile */
1930 {"GT 730M", CARD_NVIDIA_GEFORCE_GT730M}, /* Geforce 700 - midend mobile */
1931 {"GT 730", CARD_NVIDIA_GEFORCE_GT730}, /* Geforce 700 - lowend */
1932 {"GTX 690", CARD_NVIDIA_GEFORCE_GTX690}, /* Geforce 600 - highend */
1933 {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680}, /* Geforce 600 - highend */
1934 {"GTX 675MX", CARD_NVIDIA_GEFORCE_GTX675MX}, /* Geforce 600 - highend */
1935 {"GTX 670MX", CARD_NVIDIA_GEFORCE_GTX670MX}, /* Geforce 600 - highend */
1936 {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670}, /* Geforce 600 - midend high */
1937 {"GTX 660 Ti", CARD_NVIDIA_GEFORCE_GTX660TI}, /* Geforce 600 - midend high */
1938 {"GTX 660M", CARD_NVIDIA_GEFORCE_GTX660M}, /* Geforce 600 - midend high mobile */
1939 {"GTX 660", CARD_NVIDIA_GEFORCE_GTX660}, /* Geforce 600 - midend high */
1940 {"GTX 650 Ti", CARD_NVIDIA_GEFORCE_GTX650TI}, /* Geforce 600 - lowend */
1941 {"GTX 650", CARD_NVIDIA_GEFORCE_GTX650}, /* Geforce 600 - lowend */
1942 {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M}, /* Geforce 600 - midend mobile */
1943 {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M}, /* Geforce 600 - midend mobile */
1944 {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M}, /* Geforce 600 - midend mobile */
1945 {"GT 630", CARD_NVIDIA_GEFORCE_GT630}, /* Geforce 600 - lowend */
1946 {"GT 610", CARD_NVIDIA_GEFORCE_GT610}, /* Geforce 600 - lowend */
1947 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */
1948 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */
1949 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI}, /* Geforce 500 - midend */
1950 {"GTX 560M", CARD_NVIDIA_GEFORCE_GTX560M}, /* Geforce 500 - midend mobile */
1951 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */
1952 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M}, /* Geforce 500 - midend mobile */
1953 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550}, /* Geforce 500 - midend */
1954 {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M}, /* Geforce 500 - midend mobile */
1955 {"GT 525M", CARD_NVIDIA_GEFORCE_GT525M}, /* Geforce 500 - lowend mobile */
1956 {"GT 520", CARD_NVIDIA_GEFORCE_GT520}, /* Geforce 500 - lowend */
1957 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480}, /* Geforce 400 - highend */
1958 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470}, /* Geforce 400 - midend high */
1959 /* Direct 3D 10 */
1960 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465}, /* Geforce 400 - midend */
1961 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M}, /* Geforce 400 - highend mobile */
1962 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460}, /* Geforce 400 - midend */
1963 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450}, /* Geforce 400 - midend low */
1964 {"GT 440", CARD_NVIDIA_GEFORCE_GT440}, /* Geforce 400 - lowend */
1965 {"GT 430", CARD_NVIDIA_GEFORCE_GT430}, /* Geforce 400 - lowend */
1966 {"GT 425M", CARD_NVIDIA_GEFORCE_GT425M}, /* Geforce 400 - lowend mobile */
1967 {"GT 420", CARD_NVIDIA_GEFORCE_GT420}, /* Geforce 400 - lowend */
1968 {"410M", CARD_NVIDIA_GEFORCE_410M}, /* Geforce 400 - lowend mobile */
1969 {"GT 330", CARD_NVIDIA_GEFORCE_GT330}, /* Geforce 300 - highend */
1970 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1971 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1972 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1973 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1974 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M}, /* Geforce 300 - midend mobile */
1975 {"320M", CARD_NVIDIA_GEFORCE_320M}, /* Geforce 300 - midend mobile */
1976 {"315M", CARD_NVIDIA_GEFORCE_315M}, /* Geforce 300 - midend mobile */
1977 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1978 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1979 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1980 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275}, /* Geforce 200 - midend high */
1981 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260}, /* Geforce 200 - midend */
1982 {"GTS 250", CARD_NVIDIA_GEFORCE_GTS250}, /* Geforce 200 - midend */
1983 {"GT 240", CARD_NVIDIA_GEFORCE_GT240}, /* Geforce 200 - midend */
1984 {"GT 220", CARD_NVIDIA_GEFORCE_GT220}, /* Geforce 200 - lowend */
1985 {"GeForce 310", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1986 {"GeForce 305", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1987 {"GeForce 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1988 {"G 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1989 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1990 {"9800", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1991 {"9700M GT", CARD_NVIDIA_GEFORCE_9700MGT}, /* Geforce 9 - midend */
1992 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1993 {"9600", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1994 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1995 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1996 {"9500", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1997 {"9400M", CARD_NVIDIA_GEFORCE_9400M}, /* Geforce 9 - lowend */
1998 {"9400", CARD_NVIDIA_GEFORCE_9400GT}, /* Geforce 9 - lowend */
1999 {"9300", CARD_NVIDIA_GEFORCE_9300}, /* Geforce 9 - lowend low */
2000 {"9200", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
2001 {"9100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
2002 {"G 100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
2003 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX}, /* Geforce 8 - highend high */
2004 {"8800", CARD_NVIDIA_GEFORCE_8800GTS}, /* Geforce 8 - highend */
2005 {"8600M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
2006 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
2007 {"8700", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
2008 {"8600", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
2009 {"8500", CARD_NVIDIA_GEFORCE_8500GT}, /* Geforce 8 - mid-lowend */
2010 {"8400", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
2011 {"8300", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
2012 {"8200", CARD_NVIDIA_GEFORCE_8200}, /* Geforce 8 - lowend */
2013 {"8100", CARD_NVIDIA_GEFORCE_8200}, /* Geforce 8 - lowend */
2014 /* Direct 3D 9 SM3 */
2015 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
2016 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
2017 {"7950", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
2018 {"7900", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
2019 {"7800", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
2020 {"7700", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
2021 {"7600", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
2022 {"7400", CARD_NVIDIA_GEFORCE_7400}, /* Geforce 7 - lower medium */
2023 {"7300", CARD_NVIDIA_GEFORCE_7300}, /* Geforce 7 - lowend */
2024 {"6800", CARD_NVIDIA_GEFORCE_6800}, /* Geforce 6 - highend */
2025 {"6700", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
2026 {"6610", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
2027 {"6600", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
2028 /* Direct 3D 9 SM2 */
2029 {"Quadro FX", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
2030 {"5950", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
2031 {"5900", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
2032 {"5800", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
2033 {"5750", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
2034 {"5700", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
2035 {"5650", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
2036 {"5600", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
2037 {"5500", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2038 {"5300", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2039 {"5250", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2040 {"5200", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2041 {"5100", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2042 /* Direct 3D 8 */
2043 {"Quadro4", CARD_NVIDIA_GEFORCE4_TI4200},
2044 {"GeForce4 Ti", CARD_NVIDIA_GEFORCE4_TI4200}, /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800 */
2045 /* Direct 3D 7 */
2046 {"GeForce4 MX", CARD_NVIDIA_GEFORCE4_MX}, /* MX420/MX440/MX460/MX4000 */
2047 {"Quadro2 MXR", CARD_NVIDIA_GEFORCE2_MX},
2048 {"GeForce2 MX", CARD_NVIDIA_GEFORCE2_MX}, /* Geforce2 standard/MX100/MX200/MX400 */
2049 {"Quadro2", CARD_NVIDIA_GEFORCE2},
2050 {"GeForce2", CARD_NVIDIA_GEFORCE2}, /* Geforce2 GTS/Pro/Ti/Ultra */
2051 /* Direct 3D 6 */
2052 {"TNT2", CARD_NVIDIA_RIVA_TNT2}, /* Riva TNT2 standard/M64/Pro/Ultra */
2054 /* See http://developer.amd.com/resources/hardware-drivers/ati-catalyst-pc-vendor-id-1002-li/
2056 * Beware: renderer string do not match exact card model,
2057 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
2058 cards_amd_binary[] =
2060 {"RX 480", CARD_AMD_RADEON_RX_480},
2061 {"RX 460", CARD_AMD_RADEON_RX_460},
2062 {"R9 Fury Series", CARD_AMD_RADEON_R9_FURY},
2063 /* Southern Islands */
2064 {"HD 7900", CARD_AMD_RADEON_HD7900},
2065 {"HD 7800", CARD_AMD_RADEON_HD7800},
2066 {"HD 7700", CARD_AMD_RADEON_HD7700},
2067 /* Northern Islands */
2068 {"HD 6970", CARD_AMD_RADEON_HD6900},
2069 {"HD 6900", CARD_AMD_RADEON_HD6900},
2070 {"HD 6800", CARD_AMD_RADEON_HD6800},
2071 {"HD 6770M", CARD_AMD_RADEON_HD6600M},
2072 {"HD 6750M", CARD_AMD_RADEON_HD6600M},
2073 {"HD 6700", CARD_AMD_RADEON_HD6700},
2074 {"HD 6670", CARD_AMD_RADEON_HD6600},
2075 {"HD 6630M", CARD_AMD_RADEON_HD6600M},
2076 {"HD 6600M", CARD_AMD_RADEON_HD6600M},
2077 {"HD 6600", CARD_AMD_RADEON_HD6600},
2078 {"HD 6570", CARD_AMD_RADEON_HD6600},
2079 {"HD 6500M", CARD_AMD_RADEON_HD6600M},
2080 {"HD 6500", CARD_AMD_RADEON_HD6600},
2081 {"HD 6480G", CARD_AMD_RADEON_HD6480G},
2082 {"HD 6400", CARD_AMD_RADEON_HD6400},
2083 {"HD 6300", CARD_AMD_RADEON_HD6300},
2084 {"HD 6200", CARD_AMD_RADEON_HD6300},
2085 /* Evergreen */
2086 {"HD 5870", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS PRO */
2087 {"HD 5850", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS XT */
2088 {"HD 5800", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS HD58xx generic renderer string */
2089 {"HD 5770", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER XT */
2090 {"HD 5750", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER LE */
2091 {"HD 5700", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER HD57xx generic renderer string */
2092 {"HD 5670", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD XT */
2093 {"HD 5570", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
2094 {"HD 5550", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
2095 {"HD 5450", CARD_AMD_RADEON_HD5400}, /* Radeon EG CEDAR PRO */
2096 {"HD 5000", CARD_AMD_RADEON_HD5600}, /* Defaulting to HD 5600 */
2097 /* R700 */
2098 {"HD 4890", CARD_AMD_RADEON_HD4800}, /* Radeon RV790 */
2099 {"HD 4870", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
2100 {"HD 4850", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
2101 {"HD 4830", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
2102 {"HD 4800", CARD_AMD_RADEON_HD4800}, /* Radeon RV7xx HD48xx generic renderer string */
2103 {"HD 4770", CARD_AMD_RADEON_HD4700}, /* Radeon RV740 */
2104 {"HD 4700", CARD_AMD_RADEON_HD4700}, /* Radeon RV7xx HD47xx generic renderer string */
2105 {"HD 4670", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
2106 {"HD 4650", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
2107 {"HD 4600", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
2108 {"HD 4550", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
2109 {"HD 4350", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
2110 /* R600/R700 integrated */
2111 {"HD 4200M", CARD_AMD_RADEON_HD4200M},
2112 {"HD 3300", CARD_AMD_RADEON_HD3200},
2113 {"HD 3200", CARD_AMD_RADEON_HD3200},
2114 {"HD 3100", CARD_AMD_RADEON_HD3200},
2115 /* R600 */
2116 {"HD 3870", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
2117 {"HD 3850", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
2118 {"HD 2900", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
2119 {"HD 3830", CARD_AMD_RADEON_HD2600}, /* China-only midend */
2120 {"HD 3690", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
2121 {"HD 3650", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
2122 {"HD 2600", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
2123 {"HD 3470", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2124 {"HD 3450", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2125 {"HD 3430", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2126 {"HD 3400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2127 {"HD 2400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2128 {"HD 2350", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2129 /* Radeon R5xx */
2130 {"X1950", CARD_AMD_RADEON_X1600},
2131 {"X1900", CARD_AMD_RADEON_X1600},
2132 {"X1800", CARD_AMD_RADEON_X1600},
2133 {"X1650", CARD_AMD_RADEON_X1600},
2134 {"X1600", CARD_AMD_RADEON_X1600},
2135 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
2136 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
2137 {"HD 2300", CARD_AMD_RADEON_X700},
2138 {"X2500", CARD_AMD_RADEON_X700},
2139 {"X2300", CARD_AMD_RADEON_X700},
2140 {"X1550", CARD_AMD_RADEON_X700},
2141 {"X1450", CARD_AMD_RADEON_X700},
2142 {"X1400", CARD_AMD_RADEON_X700},
2143 {"X1300", CARD_AMD_RADEON_X700},
2144 {"X850", CARD_AMD_RADEON_X700},
2145 {"X800", CARD_AMD_RADEON_X700},
2146 {"X700", CARD_AMD_RADEON_X700},
2147 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400 MHz */
2148 {"Radeon Xpress", CARD_AMD_RADEON_XPRESS_200M},
2150 cards_intel[] =
2152 /* Skylake */
2153 {"Iris Pro Graphics P580", CARD_INTEL_IPP580_1},
2154 {"Skylake", CARD_INTEL_HD520_1},
2155 /* Broadwell */
2156 {"Iris Pro P6300", CARD_INTEL_IPP6300},
2157 {"Iris Pro 6200", CARD_INTEL_IP6200},
2158 {"Iris 6100", CARD_INTEL_I6100},
2159 {"Iris(TM) Graphics 6100", CARD_INTEL_I6100}, /* MacOS */
2160 /* Haswell */
2161 {"Iris Pro 5200", CARD_INTEL_IP5200_1},
2162 {"Iris 5100", CARD_INTEL_I5100_1},
2163 {"HD Graphics 5000", CARD_INTEL_HD5000}, /* MacOS */
2164 {"Haswell Mobile", CARD_INTEL_HWM},
2165 {"Iris OpenGL Engine", CARD_INTEL_HWM}, /* MacOS */
2166 /* Ivybridge */
2167 {"Ivybridge Server", CARD_INTEL_IVBS},
2168 {"Ivybridge Mobile", CARD_INTEL_IVBM},
2169 {"Ivybridge Desktop", CARD_INTEL_IVBD},
2170 {"HD Graphics 4000", CARD_INTEL_IVBD}, /* MacOS */
2171 /* Sandybridge */
2172 {"Sandybridge Server", CARD_INTEL_SNBS},
2173 {"Sandybridge Mobile", CARD_INTEL_SNBM},
2174 {"Sandybridge Desktop", CARD_INTEL_SNBD},
2175 /* Ironlake */
2176 {"Ironlake Mobile", CARD_INTEL_ILKM},
2177 {"Ironlake Desktop", CARD_INTEL_ILKD},
2178 /* G4x */
2179 {"B43", CARD_INTEL_B43},
2180 {"G41", CARD_INTEL_G41},
2181 {"G45", CARD_INTEL_G45},
2182 {"Q45", CARD_INTEL_Q45},
2183 {"Integrated Graphics Device", CARD_INTEL_IGD},
2184 {"GM45", CARD_INTEL_GM45},
2185 /* i965 */
2186 {"965GME", CARD_INTEL_965GME},
2187 {"965GM", CARD_INTEL_965GM},
2188 {"X3100", CARD_INTEL_965GM}, /* MacOS */
2189 {"946GZ", CARD_INTEL_946GZ},
2190 {"965G", CARD_INTEL_965G},
2191 {"965Q", CARD_INTEL_965Q},
2192 /* i945 */
2193 {"Pineview M", CARD_INTEL_PNVM},
2194 {"Pineview G", CARD_INTEL_PNVG},
2195 {"IGD", CARD_INTEL_PNVG},
2196 {"Q33", CARD_INTEL_Q33},
2197 {"G33", CARD_INTEL_G33},
2198 {"Q35", CARD_INTEL_Q35},
2199 {"945GME", CARD_INTEL_945GME},
2200 {"945GM", CARD_INTEL_945GM},
2201 {"GMA 950", CARD_INTEL_945GM}, /* MacOS */
2202 {"945G", CARD_INTEL_945G},
2203 /* i915 */
2204 {"915GM", CARD_INTEL_915GM},
2205 {"E7221G", CARD_INTEL_E7221G},
2206 {"915G", CARD_INTEL_915G},
2207 /* i8xx */
2208 {"865G", CARD_INTEL_865G},
2209 {"845G", CARD_INTEL_845G},
2210 {"855GM", CARD_INTEL_855GM},
2211 {"830M", CARD_INTEL_830M},
2213 /* 20101109 - These are never returned by current Gallium radeon
2214 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351. */
2215 cards_amd_mesa[] =
2217 /* Polaris 10/11 */
2218 {"POLARIS10", CARD_AMD_RADEON_RX_480},
2219 {"POLARIS11", CARD_AMD_RADEON_RX_460},
2220 /* Volcanic Islands */
2221 {"FIJI", CARD_AMD_RADEON_R9_FURY},
2222 {"TONGA", CARD_AMD_RADEON_R9_285},
2223 /* Sea Islands */
2224 {"HAWAII", CARD_AMD_RADEON_R9_290},
2225 {"KAVERI", CARD_AMD_RADEON_R7 },
2226 {"KABINI", CARD_AMD_RADEON_R3 },
2227 {"BONAIRE", CARD_AMD_RADEON_HD8770},
2228 /* Southern Islands */
2229 {"OLAND", CARD_AMD_RADEON_HD8670},
2230 {"HAINAN", CARD_AMD_RADEON_HD8600M},
2231 {"TAHITI", CARD_AMD_RADEON_HD7900},
2232 {"PITCAIRN", CARD_AMD_RADEON_HD7800},
2233 {"CAPE VERDE", CARD_AMD_RADEON_HD7700},
2234 /* Northern Islands */
2235 {"ARUBA", CARD_AMD_RADEON_HD7660D},
2236 {"CAYMAN", CARD_AMD_RADEON_HD6900},
2237 {"BARTS", CARD_AMD_RADEON_HD6800},
2238 {"TURKS", CARD_AMD_RADEON_HD6600},
2239 {"SUMO2", CARD_AMD_RADEON_HD6410D}, /* SUMO2 first, because we do a strstr(). */
2240 {"SUMO", CARD_AMD_RADEON_HD6550D},
2241 {"CAICOS", CARD_AMD_RADEON_HD6400},
2242 {"PALM", CARD_AMD_RADEON_HD6300},
2243 /* Evergreen */
2244 {"HEMLOCK", CARD_AMD_RADEON_HD5900},
2245 {"CYPRESS", CARD_AMD_RADEON_HD5800},
2246 {"JUNIPER", CARD_AMD_RADEON_HD5700},
2247 {"REDWOOD", CARD_AMD_RADEON_HD5600},
2248 {"CEDAR", CARD_AMD_RADEON_HD5400},
2249 /* R700 */
2250 {"R700", CARD_AMD_RADEON_HD4800},
2251 {"RV790", CARD_AMD_RADEON_HD4800},
2252 {"RV770", CARD_AMD_RADEON_HD4800},
2253 {"RV740", CARD_AMD_RADEON_HD4700},
2254 {"RV730", CARD_AMD_RADEON_HD4600},
2255 {"RV710", CARD_AMD_RADEON_HD4350},
2256 /* R600/R700 integrated */
2257 {"RS880", CARD_AMD_RADEON_HD4200M},
2258 {"RS780", CARD_AMD_RADEON_HD3200},
2259 /* R600 */
2260 {"R680", CARD_AMD_RADEON_HD2900},
2261 {"R600", CARD_AMD_RADEON_HD2900},
2262 {"RV670", CARD_AMD_RADEON_HD3850},
2263 {"RV635", CARD_AMD_RADEON_HD2600},
2264 {"RV630", CARD_AMD_RADEON_HD2600},
2265 {"RV620", CARD_AMD_RADEON_HD2350},
2266 {"RV610", CARD_AMD_RADEON_HD2350},
2267 /* R500 */
2268 {"R580", CARD_AMD_RADEON_X1600},
2269 {"R520", CARD_AMD_RADEON_X1600},
2270 {"RV570", CARD_AMD_RADEON_X1600},
2271 {"RV560", CARD_AMD_RADEON_X1600},
2272 {"RV535", CARD_AMD_RADEON_X1600},
2273 {"RV530", CARD_AMD_RADEON_X1600},
2274 {"RV516", CARD_AMD_RADEON_X700},
2275 {"RV515", CARD_AMD_RADEON_X700},
2276 /* R400 */
2277 {"R481", CARD_AMD_RADEON_X700},
2278 {"R480", CARD_AMD_RADEON_X700},
2279 {"R430", CARD_AMD_RADEON_X700},
2280 {"R423", CARD_AMD_RADEON_X700},
2281 {"R420", CARD_AMD_RADEON_X700},
2282 {"R410", CARD_AMD_RADEON_X700},
2283 {"RV410", CARD_AMD_RADEON_X700},
2284 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400 MHz */
2285 {"RS740", CARD_AMD_RADEON_XPRESS_200M},
2286 {"RS690", CARD_AMD_RADEON_XPRESS_200M},
2287 {"RS600", CARD_AMD_RADEON_XPRESS_200M},
2288 {"RS485", CARD_AMD_RADEON_XPRESS_200M},
2289 {"RS482", CARD_AMD_RADEON_XPRESS_200M},
2290 {"RS480", CARD_AMD_RADEON_XPRESS_200M},
2291 {"RS400", CARD_AMD_RADEON_XPRESS_200M},
2292 {"RC410", CARD_AMD_RADEON_XPRESS_200M},
2293 /* R300 */
2294 {"R360", CARD_AMD_RADEON_9500},
2295 {"R350", CARD_AMD_RADEON_9500},
2296 {"R300", CARD_AMD_RADEON_9500},
2297 {"RV380", CARD_AMD_RADEON_9500},
2298 {"RV370", CARD_AMD_RADEON_9500},
2299 {"RV360", CARD_AMD_RADEON_9500},
2300 {"RV351", CARD_AMD_RADEON_9500},
2301 {"RV350", CARD_AMD_RADEON_9500},
2303 cards_nvidia_mesa[] =
2305 /* Maxwell */
2306 {"NV124", CARD_NVIDIA_GEFORCE_GTX970},
2307 {"NV120", CARD_NVIDIA_GEFORCE_GTX980TI},
2308 {"NV118", CARD_NVIDIA_GEFORCE_840M},
2309 {"NV117", CARD_NVIDIA_GEFORCE_GTX750},
2310 /* Kepler */
2311 {"NV108", CARD_NVIDIA_GEFORCE_GT740M},
2312 {"NVF1", CARD_NVIDIA_GEFORCE_GTX780TI},
2313 {"NVF0", CARD_NVIDIA_GEFORCE_GTX780},
2314 {"NVE6", CARD_NVIDIA_GEFORCE_GTX770M},
2315 {"NVE4", CARD_NVIDIA_GEFORCE_GTX680}, /* 690 / 675MX / 760TI */
2316 /* Fermi */
2317 {"NVD9", CARD_NVIDIA_GEFORCE_GT520},
2318 {"NVD7", CARD_NVIDIA_GEFORCE_820M},
2319 {"NVCF", CARD_NVIDIA_GEFORCE_GTX550},
2320 {"NVCE", CARD_NVIDIA_GEFORCE_GTX560},
2321 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570},
2322 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460},
2323 {"NVC3", CARD_NVIDIA_GEFORCE_GT440},
2324 {"NVC1", CARD_NVIDIA_GEFORCE_GT420},
2325 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480},
2326 /* Tesla */
2327 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M},
2328 {"NVAC", CARD_NVIDIA_GEFORCE_8200},
2329 {"NVAA", CARD_NVIDIA_GEFORCE_8200}, /* 8100 */
2330 {"NVA8", CARD_NVIDIA_GEFORCE_210},
2331 {"NVA5", CARD_NVIDIA_GEFORCE_GT220},
2332 {"NVA3", CARD_NVIDIA_GEFORCE_GT240},
2333 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280},
2334 {"NV98", CARD_NVIDIA_GEFORCE_9200},
2335 {"NV96", CARD_NVIDIA_GEFORCE_9400GT},
2336 {"NV94", CARD_NVIDIA_GEFORCE_9600GT},
2337 {"NV92", CARD_NVIDIA_GEFORCE_9800GT},
2338 {"NV86", CARD_NVIDIA_GEFORCE_8500GT},
2339 {"NV84", CARD_NVIDIA_GEFORCE_8600GT},
2340 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX},
2341 /* Curie */
2342 {"NV68", CARD_NVIDIA_GEFORCE_6200}, /* 7050 */
2343 {"NV67", CARD_NVIDIA_GEFORCE_6200}, /* 7000M */
2344 {"NV63", CARD_NVIDIA_GEFORCE_6200}, /* 7100 */
2345 {"NV4E", CARD_NVIDIA_GEFORCE_6200}, /* 6100 Go / 6150 Go */
2346 {"NV4C", CARD_NVIDIA_GEFORCE_6200}, /* 6150SE */
2347 {"NV4B", CARD_NVIDIA_GEFORCE_7600},
2348 {"NV4A", CARD_NVIDIA_GEFORCE_6200},
2349 {"NV49", CARD_NVIDIA_GEFORCE_7800GT}, /* 7900 */
2350 {"NV47", CARD_NVIDIA_GEFORCE_7800GT},
2351 {"NV46", CARD_NVIDIA_GEFORCE_7400},
2352 {"NV45", CARD_NVIDIA_GEFORCE_6800},
2353 {"NV44", CARD_NVIDIA_GEFORCE_6200},
2354 {"NV43", CARD_NVIDIA_GEFORCE_6600GT},
2355 {"NV42", CARD_NVIDIA_GEFORCE_6800},
2356 {"NV41", CARD_NVIDIA_GEFORCE_6800},
2357 {"NV40", CARD_NVIDIA_GEFORCE_6800},
2358 /* Rankine */
2359 {"NV38", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5950 Ultra */
2360 {"NV36", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5700/5750 */
2361 {"NV35", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5900 */
2362 {"NV34", CARD_NVIDIA_GEFORCEFX_5200},
2363 {"NV31", CARD_NVIDIA_GEFORCEFX_5600},
2364 {"NV30", CARD_NVIDIA_GEFORCEFX_5800},
2365 /* Kelvin */
2366 {"nv28", CARD_NVIDIA_GEFORCE4_TI4200},
2367 {"nv25", CARD_NVIDIA_GEFORCE4_TI4200},
2368 {"nv20", CARD_NVIDIA_GEFORCE3},
2369 /* Celsius */
2370 {"nv1F", CARD_NVIDIA_GEFORCE4_MX}, /* GF4 MX IGP */
2371 {"nv1A", CARD_NVIDIA_GEFORCE2}, /* GF2 IGP */
2372 {"nv18", CARD_NVIDIA_GEFORCE4_MX},
2373 {"nv17", CARD_NVIDIA_GEFORCE4_MX},
2374 {"nv16", CARD_NVIDIA_GEFORCE2},
2375 {"nv15", CARD_NVIDIA_GEFORCE2},
2376 {"nv11", CARD_NVIDIA_GEFORCE2_MX},
2377 {"nv10", CARD_NVIDIA_GEFORCE},
2378 /* Fahrenheit */
2379 {"nv05", CARD_NVIDIA_RIVA_TNT2},
2380 {"nv04", CARD_NVIDIA_RIVA_TNT},
2381 {"nv03", CARD_NVIDIA_RIVA_128},
2383 cards_vmware[] =
2385 {"SVGA3D", CARD_VMWARE_SVGA3D},
2388 static const struct gl_vendor_selection
2390 enum wined3d_gl_vendor gl_vendor;
2391 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
2392 const struct wined3d_renderer_table *cards; /* To be used as cards[], pointer to the first member in an array */
2393 size_t cards_size; /* Number of entries in the array above */
2395 amd_gl_vendor_table[] =
2397 {GL_VENDOR_APPLE, "Apple OSX AMD/ATI binary driver", cards_amd_binary, ARRAY_SIZE(cards_amd_binary)},
2398 {GL_VENDOR_FGLRX, "AMD/ATI binary driver", cards_amd_binary, ARRAY_SIZE(cards_amd_binary)},
2399 {GL_VENDOR_MESA, "Mesa AMD/ATI driver", cards_amd_mesa, ARRAY_SIZE(cards_amd_mesa)},
2401 nvidia_gl_vendor_table[] =
2403 {GL_VENDOR_APPLE, "Apple OSX NVidia binary driver", cards_nvidia_binary, ARRAY_SIZE(cards_nvidia_binary)},
2404 {GL_VENDOR_MESA, "Mesa Nouveau driver", cards_nvidia_mesa, ARRAY_SIZE(cards_nvidia_mesa)},
2405 {GL_VENDOR_NVIDIA, "Nvidia binary driver", cards_nvidia_binary, ARRAY_SIZE(cards_nvidia_binary)},
2407 vmware_gl_vendor_table[] =
2409 {GL_VENDOR_MESA, "VMware driver", cards_vmware, ARRAY_SIZE(cards_vmware)},
2411 intel_gl_vendor_table[] =
2413 {GL_VENDOR_APPLE, "Apple OSX Intel binary driver", cards_intel, ARRAY_SIZE(cards_intel)},
2414 {GL_VENDOR_MESA, "Mesa Intel driver", cards_intel, ARRAY_SIZE(cards_intel)},
2417 static const enum wined3d_pci_device
2418 card_fallback_nvidia[] =
2420 CARD_NVIDIA_RIVA_128, /* D3D5 */
2421 CARD_NVIDIA_RIVA_TNT, /* D3D6 */
2422 CARD_NVIDIA_GEFORCE, /* D3D7 */
2423 CARD_NVIDIA_GEFORCE3, /* D3D8 */
2424 CARD_NVIDIA_GEFORCEFX_5800, /* D3D9_SM2 */
2425 CARD_NVIDIA_GEFORCE_6800, /* D3D9_SM3 */
2426 CARD_NVIDIA_GEFORCE_8800GTX, /* D3D10 */
2427 CARD_NVIDIA_GEFORCE_GTX470, /* D3D11 */
2429 card_fallback_amd[] =
2431 CARD_AMD_RAGE_128PRO, /* D3D5 */
2432 CARD_AMD_RAGE_128PRO, /* D3D6 */
2433 CARD_AMD_RADEON_7200, /* D3D7 */
2434 CARD_AMD_RADEON_8500, /* D3D8 */
2435 CARD_AMD_RADEON_9500, /* D3D9_SM2 */
2436 CARD_AMD_RADEON_X1600, /* D3D9_SM3 */
2437 CARD_AMD_RADEON_HD2900, /* D3D10 */
2438 CARD_AMD_RADEON_HD5600, /* D3D11 */
2440 card_fallback_intel[] =
2442 CARD_INTEL_845G, /* D3D5 */
2443 CARD_INTEL_845G, /* D3D6 */
2444 CARD_INTEL_845G, /* D3D7 */
2445 CARD_INTEL_915G, /* D3D8 */
2446 CARD_INTEL_915G, /* D3D9_SM2 */
2447 CARD_INTEL_945G, /* D3D9_SM3 */
2448 CARD_INTEL_G45, /* D3D10 */
2449 CARD_INTEL_IVBD, /* D3D11 */
2451 C_ASSERT(ARRAY_SIZE(card_fallback_nvidia) == WINED3D_D3D_LEVEL_COUNT);
2452 C_ASSERT(ARRAY_SIZE(card_fallback_amd) == WINED3D_D3D_LEVEL_COUNT);
2453 C_ASSERT(ARRAY_SIZE(card_fallback_intel) == WINED3D_D3D_LEVEL_COUNT);
2455 static enum wined3d_pci_device select_card_handler(const struct gl_vendor_selection *table,
2456 unsigned int table_size, enum wined3d_gl_vendor gl_vendor, const char *gl_renderer)
2458 unsigned int i, j;
2460 for (i = 0; i < table_size; ++i)
2462 if (table[i].gl_vendor != gl_vendor)
2463 continue;
2465 TRACE("Applying card selector \"%s\".\n", table[i].description);
2467 for (j = 0; j < table[i].cards_size; ++j)
2469 if (strstr(gl_renderer, table[i].cards[j].renderer))
2470 return table[i].cards[j].id;
2472 return PCI_DEVICE_NONE;
2474 FIXME("Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n",
2475 gl_vendor, debugstr_a(gl_renderer));
2477 return PCI_DEVICE_NONE;
2480 static const struct
2482 enum wined3d_pci_vendor card_vendor;
2483 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
2484 const struct gl_vendor_selection *gl_vendor_selection;
2485 unsigned int gl_vendor_count;
2486 const enum wined3d_pci_device *card_fallback; /* An array with D3D_LEVEL_COUNT elements */
2488 card_vendor_table[] =
2490 {HW_VENDOR_AMD, "AMD", amd_gl_vendor_table,
2491 ARRAY_SIZE(amd_gl_vendor_table),
2492 card_fallback_amd},
2493 {HW_VENDOR_NVIDIA, "Nvidia", nvidia_gl_vendor_table,
2494 ARRAY_SIZE(nvidia_gl_vendor_table),
2495 card_fallback_nvidia},
2496 {HW_VENDOR_VMWARE, "VMware", vmware_gl_vendor_table,
2497 ARRAY_SIZE(vmware_gl_vendor_table),
2498 card_fallback_amd},
2499 {HW_VENDOR_INTEL, "Intel", intel_gl_vendor_table,
2500 ARRAY_SIZE(intel_gl_vendor_table),
2501 card_fallback_intel},
2505 static enum wined3d_pci_device wined3d_guess_card(const struct shader_caps *shader_caps, const struct fragment_caps *fragment_caps,
2506 DWORD glsl_version, const char *gl_renderer, enum wined3d_gl_vendor *gl_vendor, enum wined3d_pci_vendor *card_vendor)
2508 /* A Direct3D device object contains the PCI id (vendor + device) of the
2509 * videocard which is used for rendering. Various applications use this
2510 * information to get a rough estimation of the features of the card and
2511 * some might use it for enabling 3d effects only on certain types of
2512 * videocards. In some cases games might even use it to work around bugs
2513 * which happen on certain videocards/driver combinations. The problem is
2514 * that OpenGL only exposes a rendering string containing the name of the
2515 * videocard and not the PCI id.
2517 * Various games depend on the PCI id, so somehow we need to provide one.
2518 * A simple option is to parse the renderer string and translate this to
2519 * the right PCI id. This is a lot of work because there are more than 200
2520 * GPUs just for Nvidia. Various cards share the same renderer string, so
2521 * the amount of code might be 'small' but there are quite a number of
2522 * exceptions which would make this a pain to maintain. Another way would
2523 * be to query the PCI id from the operating system (assuming this is the
2524 * videocard which is used for rendering which is not always the case).
2525 * This would work but it is not very portable. Second it would not work
2526 * well in, let's say, a remote X situation in which the amount of 3d
2527 * features which can be used is limited.
2529 * As said most games only use the PCI id to get an indication of the
2530 * capabilities of the card. It doesn't really matter if the given id is
2531 * the correct one if we return the id of a card with similar 3d features.
2533 * The code below checks the OpenGL capabilities of a videocard and matches
2534 * that to a certain level of Direct3D functionality. Once a card passes
2535 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
2536 * least a GeforceFX. To give a better estimate we do a basic check on the
2537 * renderer string but if that won't pass we return a default card. This
2538 * way is better than maintaining a full card database as even without a
2539 * full database we can return a card with similar features. Second the
2540 * size of the database can be made quite small because when you know what
2541 * type of 3d functionality a card has, you know to which GPU family the
2542 * GPU must belong. Because of this you only have to check a small part of
2543 * the renderer string to distinguish between different models from that
2544 * family.
2546 * The code also selects a default amount of video memory which we will
2547 * use for an estimation of the amount of free texture memory. In case of
2548 * real D3D the amount of texture memory includes video memory and system
2549 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2550 * HyperMemory). We don't know how much system memory can be addressed by
2551 * the system but we can make a reasonable estimation about the amount of
2552 * video memory. If the value is slightly wrong it doesn't matter as we
2553 * didn't include AGP-like memory which makes the amount of addressable
2554 * memory higher and second OpenGL isn't that critical it moves to system
2555 * memory behind our backs if really needed. Note that the amount of video
2556 * memory can be overruled using a registry setting. */
2558 unsigned int i;
2559 enum wined3d_d3d_level d3d_level = d3d_level_from_caps(shader_caps, fragment_caps, glsl_version);
2560 enum wined3d_pci_device device;
2562 for (i = 0; i < ARRAY_SIZE(card_vendor_table); ++i)
2564 if (card_vendor_table[i].card_vendor != *card_vendor)
2565 continue;
2567 TRACE("Applying card selector \"%s\".\n", card_vendor_table[i].description);
2568 device = select_card_handler(card_vendor_table[i].gl_vendor_selection,
2569 card_vendor_table[i].gl_vendor_count, *gl_vendor, gl_renderer);
2570 if (device != PCI_DEVICE_NONE)
2571 return device;
2573 TRACE("Unrecognized renderer %s, falling back to default.\n", debugstr_a(gl_renderer));
2574 return card_vendor_table[i].card_fallback[d3d_level];
2577 FIXME("No card selector available for card vendor %04x (using GL_RENDERER %s).\n",
2578 *card_vendor, debugstr_a(gl_renderer));
2580 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. */
2581 *card_vendor = HW_VENDOR_NVIDIA;
2582 return card_fallback_nvidia[d3d_level];
2585 static const struct wined3d_vertex_pipe_ops *select_vertex_implementation(const struct wined3d_gl_info *gl_info,
2586 const struct wined3d_shader_backend_ops *shader_backend_ops)
2588 if (shader_backend_ops == &glsl_shader_backend && gl_info->supported[ARB_VERTEX_SHADER])
2589 return &glsl_vertex_pipe;
2590 return &ffp_vertex_pipe;
2593 static const struct fragment_pipeline *select_fragment_implementation(const struct wined3d_gl_info *gl_info,
2594 const struct wined3d_shader_backend_ops *shader_backend_ops)
2596 if (shader_backend_ops == &glsl_shader_backend && gl_info->supported[ARB_FRAGMENT_SHADER])
2597 return &glsl_fragment_pipe;
2598 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2599 return &arbfp_fragment_pipeline;
2600 if (gl_info->supported[ATI_FRAGMENT_SHADER])
2601 return &atifs_fragment_pipeline;
2602 if (gl_info->supported[NV_REGISTER_COMBINERS] && gl_info->supported[NV_TEXTURE_SHADER2])
2603 return &nvts_fragment_pipeline;
2604 if (gl_info->supported[NV_REGISTER_COMBINERS])
2605 return &nvrc_fragment_pipeline;
2606 return &ffp_fragment_pipeline;
2609 static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info)
2611 BOOL glsl = wined3d_settings.glslRequested && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20);
2613 if (glsl && gl_info->supported[ARB_VERTEX_SHADER] && gl_info->supported[ARB_FRAGMENT_SHADER])
2614 return &glsl_shader_backend;
2615 if (gl_info->supported[ARB_VERTEX_PROGRAM] && gl_info->supported[ARB_FRAGMENT_PROGRAM])
2616 return &arb_program_shader_backend;
2617 if (glsl && (gl_info->supported[ARB_VERTEX_SHADER] || gl_info->supported[ARB_FRAGMENT_SHADER]))
2618 return &glsl_shader_backend;
2619 if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_FRAGMENT_PROGRAM])
2620 return &arb_program_shader_backend;
2621 return &none_shader_backend;
2624 static void parse_extension_string(struct wined3d_gl_info *gl_info, const char *extensions,
2625 const struct wined3d_extension_map *map, UINT entry_count)
2627 while (*extensions)
2629 const char *start;
2630 size_t len;
2631 UINT i;
2633 while (isspace(*extensions))
2634 ++extensions;
2635 start = extensions;
2636 while (!isspace(*extensions) && *extensions)
2637 ++extensions;
2639 len = extensions - start;
2640 if (!len)
2641 continue;
2643 TRACE("- %s.\n", debugstr_an(start, len));
2645 for (i = 0; i < entry_count; ++i)
2647 if (len == strlen(map[i].extension_string)
2648 && !memcmp(start, map[i].extension_string, len))
2650 TRACE(" FOUND: %s support.\n", map[i].extension_string);
2651 gl_info->supported[map[i].extension] = TRUE;
2652 break;
2658 static void enumerate_gl_extensions(struct wined3d_gl_info *gl_info,
2659 const struct wined3d_extension_map *map, unsigned int map_entries_count)
2661 const char *gl_extension_name;
2662 unsigned int i, j;
2663 GLint extensions_count;
2665 gl_info->gl_ops.gl.p_glGetIntegerv(GL_NUM_EXTENSIONS, &extensions_count);
2666 for (i = 0; i < extensions_count; ++i)
2668 gl_extension_name = (const char *)GL_EXTCALL(glGetStringi(GL_EXTENSIONS, i));
2669 TRACE("- %s.\n", debugstr_a(gl_extension_name));
2670 for (j = 0; j < map_entries_count; ++j)
2672 if (!strcmp(gl_extension_name, map[j].extension_string))
2674 TRACE("FOUND: %s support.\n", map[j].extension_string);
2675 gl_info->supported[map[j].extension] = TRUE;
2676 break;
2682 static void load_gl_funcs(struct wined3d_gl_info *gl_info)
2684 #define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
2685 /* GL_APPLE_fence */
2686 USE_GL_FUNC(glDeleteFencesAPPLE)
2687 USE_GL_FUNC(glFinishFenceAPPLE)
2688 USE_GL_FUNC(glFinishObjectAPPLE)
2689 USE_GL_FUNC(glGenFencesAPPLE)
2690 USE_GL_FUNC(glIsFenceAPPLE)
2691 USE_GL_FUNC(glSetFenceAPPLE)
2692 USE_GL_FUNC(glTestFenceAPPLE)
2693 USE_GL_FUNC(glTestObjectAPPLE)
2694 /* GL_APPLE_flush_buffer_range */
2695 USE_GL_FUNC(glBufferParameteriAPPLE)
2696 USE_GL_FUNC(glFlushMappedBufferRangeAPPLE)
2697 /* GL_ARB_base_instance */
2698 USE_GL_FUNC(glDrawArraysInstancedBaseInstance)
2699 USE_GL_FUNC(glDrawElementsInstancedBaseVertexBaseInstance)
2700 /* GL_ARB_blend_func_extended */
2701 USE_GL_FUNC(glBindFragDataLocationIndexed)
2702 USE_GL_FUNC(glGetFragDataIndex)
2703 /* GL_ARB_clear_buffer_object */
2704 USE_GL_FUNC(glClearBufferData)
2705 USE_GL_FUNC(glClearBufferSubData)
2706 /* GL_ARB_clear_texture */
2707 USE_GL_FUNC(glClearTexImage)
2708 USE_GL_FUNC(glClearTexSubImage)
2709 /* GL_ARB_clip_control */
2710 USE_GL_FUNC(glClipControl)
2711 /* GL_ARB_color_buffer_float */
2712 USE_GL_FUNC(glClampColorARB)
2713 /* GL_ARB_compute_shader */
2714 USE_GL_FUNC(glDispatchCompute)
2715 USE_GL_FUNC(glDispatchComputeIndirect)
2716 /* GL_ARB_copy_buffer */
2717 USE_GL_FUNC(glCopyBufferSubData)
2718 /* GL_ARB_copy_image */
2719 USE_GL_FUNC(glCopyImageSubData)
2720 /* GL_ARB_debug_output */
2721 USE_GL_FUNC(glDebugMessageCallbackARB)
2722 USE_GL_FUNC(glDebugMessageControlARB)
2723 USE_GL_FUNC(glDebugMessageInsertARB)
2724 USE_GL_FUNC(glGetDebugMessageLogARB)
2725 /* GL_ARB_draw_buffers */
2726 USE_GL_FUNC(glDrawBuffersARB)
2727 /* GL_ARB_draw_elements_base_vertex */
2728 USE_GL_FUNC(glDrawElementsBaseVertex)
2729 USE_GL_FUNC(glDrawElementsInstancedBaseVertex)
2730 USE_GL_FUNC(glDrawRangeElementsBaseVertex)
2731 USE_GL_FUNC(glMultiDrawElementsBaseVertex)
2732 /* GL_ARB_draw_indirect */
2733 USE_GL_FUNC(glDrawArraysIndirect)
2734 USE_GL_FUNC(glDrawElementsIndirect)
2735 /* GL_ARB_draw_instanced */
2736 USE_GL_FUNC(glDrawArraysInstancedARB)
2737 USE_GL_FUNC(glDrawElementsInstancedARB)
2738 /* GL_ARB_ES2_compatibility */
2739 USE_GL_FUNC(glReleaseShaderCompiler)
2740 USE_GL_FUNC(glShaderBinary)
2741 USE_GL_FUNC(glGetShaderPrecisionFormat)
2742 USE_GL_FUNC(glDepthRangef)
2743 USE_GL_FUNC(glClearDepthf)
2744 /* GL_ARB_framebuffer_no_attachments */
2745 USE_GL_FUNC(glFramebufferParameteri)
2746 /* GL_ARB_framebuffer_object */
2747 USE_GL_FUNC(glBindFramebuffer)
2748 USE_GL_FUNC(glBindRenderbuffer)
2749 USE_GL_FUNC(glBlitFramebuffer)
2750 USE_GL_FUNC(glCheckFramebufferStatus)
2751 USE_GL_FUNC(glDeleteFramebuffers)
2752 USE_GL_FUNC(glDeleteRenderbuffers)
2753 USE_GL_FUNC(glFramebufferRenderbuffer)
2754 USE_GL_FUNC(glFramebufferTexture)
2755 USE_GL_FUNC(glFramebufferTexture1D)
2756 USE_GL_FUNC(glFramebufferTexture2D)
2757 USE_GL_FUNC(glFramebufferTexture3D)
2758 USE_GL_FUNC(glFramebufferTextureLayer)
2759 USE_GL_FUNC(glGenFramebuffers)
2760 USE_GL_FUNC(glGenRenderbuffers)
2761 USE_GL_FUNC(glGenerateMipmap)
2762 USE_GL_FUNC(glGetFramebufferAttachmentParameteriv)
2763 USE_GL_FUNC(glGetRenderbufferParameteriv)
2764 USE_GL_FUNC(glIsFramebuffer)
2765 USE_GL_FUNC(glIsRenderbuffer)
2766 USE_GL_FUNC(glRenderbufferStorage)
2767 USE_GL_FUNC(glRenderbufferStorageMultisample)
2768 /* GL_ARB_geometry_shader4 */
2769 USE_GL_FUNC(glFramebufferTextureARB)
2770 USE_GL_FUNC(glFramebufferTextureFaceARB)
2771 USE_GL_FUNC(glFramebufferTextureLayerARB)
2772 USE_GL_FUNC(glProgramParameteriARB)
2773 /* GL_ARB_instanced_arrays */
2774 USE_GL_FUNC(glVertexAttribDivisorARB)
2775 /* GL_ARB_internalformat_query */
2776 USE_GL_FUNC(glGetInternalformativ)
2777 /* GL_ARB_internalformat_query2 */
2778 USE_GL_FUNC(glGetInternalformati64v)
2779 /* GL_ARB_map_buffer_range */
2780 USE_GL_FUNC(glFlushMappedBufferRange)
2781 USE_GL_FUNC(glMapBufferRange)
2782 /* GL_ARB_multisample */
2783 USE_GL_FUNC(glSampleCoverageARB)
2784 /* GL_ARB_multitexture */
2785 USE_GL_FUNC(glActiveTextureARB)
2786 USE_GL_FUNC(glClientActiveTextureARB)
2787 USE_GL_FUNC(glMultiTexCoord1fARB)
2788 USE_GL_FUNC(glMultiTexCoord1fvARB)
2789 USE_GL_FUNC(glMultiTexCoord2fARB)
2790 USE_GL_FUNC(glMultiTexCoord2fvARB)
2791 USE_GL_FUNC(glMultiTexCoord2svARB)
2792 USE_GL_FUNC(glMultiTexCoord3fARB)
2793 USE_GL_FUNC(glMultiTexCoord3fvARB)
2794 USE_GL_FUNC(glMultiTexCoord4fARB)
2795 USE_GL_FUNC(glMultiTexCoord4fvARB)
2796 USE_GL_FUNC(glMultiTexCoord4svARB)
2797 /* GL_ARB_occlusion_query */
2798 USE_GL_FUNC(glBeginQueryARB)
2799 USE_GL_FUNC(glDeleteQueriesARB)
2800 USE_GL_FUNC(glEndQueryARB)
2801 USE_GL_FUNC(glGenQueriesARB)
2802 USE_GL_FUNC(glGetQueryivARB)
2803 USE_GL_FUNC(glGetQueryObjectivARB)
2804 USE_GL_FUNC(glGetQueryObjectuivARB)
2805 USE_GL_FUNC(glIsQueryARB)
2806 /* GL_ARB_point_parameters */
2807 USE_GL_FUNC(glPointParameterfARB)
2808 USE_GL_FUNC(glPointParameterfvARB)
2809 /* GL_ARB_provoking_vertex */
2810 USE_GL_FUNC(glProvokingVertex)
2811 /* GL_ARB_sampler_objects */
2812 USE_GL_FUNC(glGenSamplers)
2813 USE_GL_FUNC(glDeleteSamplers)
2814 USE_GL_FUNC(glIsSampler)
2815 USE_GL_FUNC(glBindSampler)
2816 USE_GL_FUNC(glSamplerParameteri)
2817 USE_GL_FUNC(glSamplerParameterf)
2818 USE_GL_FUNC(glSamplerParameteriv)
2819 USE_GL_FUNC(glSamplerParameterfv)
2820 USE_GL_FUNC(glSamplerParameterIiv)
2821 USE_GL_FUNC(glSamplerParameterIuiv)
2822 USE_GL_FUNC(glGetSamplerParameteriv)
2823 USE_GL_FUNC(glGetSamplerParameterfv)
2824 USE_GL_FUNC(glGetSamplerParameterIiv)
2825 USE_GL_FUNC(glGetSamplerParameterIuiv)
2826 /* GL_ARB_shader_atomic_counters */
2827 USE_GL_FUNC(glGetActiveAtomicCounterBufferiv)
2828 /* GL_ARB_shader_image_load_store */
2829 USE_GL_FUNC(glBindImageTexture)
2830 USE_GL_FUNC(glMemoryBarrier)
2831 /* GL_ARB_shader_objects */
2832 USE_GL_FUNC(glAttachObjectARB)
2833 USE_GL_FUNC(glBindAttribLocationARB)
2834 USE_GL_FUNC(glCompileShaderARB)
2835 USE_GL_FUNC(glCreateProgramObjectARB)
2836 USE_GL_FUNC(glCreateShaderObjectARB)
2837 USE_GL_FUNC(glDeleteObjectARB)
2838 USE_GL_FUNC(glDetachObjectARB)
2839 USE_GL_FUNC(glGetActiveUniformARB)
2840 USE_GL_FUNC(glGetAttachedObjectsARB)
2841 USE_GL_FUNC(glGetAttribLocationARB)
2842 USE_GL_FUNC(glGetHandleARB)
2843 USE_GL_FUNC(glGetInfoLogARB)
2844 USE_GL_FUNC(glGetObjectParameterfvARB)
2845 USE_GL_FUNC(glGetObjectParameterivARB)
2846 USE_GL_FUNC(glGetShaderSourceARB)
2847 USE_GL_FUNC(glGetUniformLocationARB)
2848 USE_GL_FUNC(glGetUniformfvARB)
2849 USE_GL_FUNC(glGetUniformivARB)
2850 USE_GL_FUNC(glLinkProgramARB)
2851 USE_GL_FUNC(glShaderSourceARB)
2852 USE_GL_FUNC(glUniform1fARB)
2853 USE_GL_FUNC(glUniform1fvARB)
2854 USE_GL_FUNC(glUniform1iARB)
2855 USE_GL_FUNC(glUniform1ivARB)
2856 USE_GL_FUNC(glUniform2fARB)
2857 USE_GL_FUNC(glUniform2fvARB)
2858 USE_GL_FUNC(glUniform2iARB)
2859 USE_GL_FUNC(glUniform2ivARB)
2860 USE_GL_FUNC(glUniform3fARB)
2861 USE_GL_FUNC(glUniform3fvARB)
2862 USE_GL_FUNC(glUniform3iARB)
2863 USE_GL_FUNC(glUniform3ivARB)
2864 USE_GL_FUNC(glUniform4fARB)
2865 USE_GL_FUNC(glUniform4fvARB)
2866 USE_GL_FUNC(glUniform4iARB)
2867 USE_GL_FUNC(glUniform4ivARB)
2868 USE_GL_FUNC(glUniformMatrix2fvARB)
2869 USE_GL_FUNC(glUniformMatrix3fvARB)
2870 USE_GL_FUNC(glUniformMatrix4fvARB)
2871 USE_GL_FUNC(glUseProgramObjectARB)
2872 USE_GL_FUNC(glValidateProgramARB)
2873 /* GL_ARB_shader_storage_buffer_object */
2874 USE_GL_FUNC(glShaderStorageBlockBinding)
2875 /* GL_ARB_sync */
2876 USE_GL_FUNC(glClientWaitSync)
2877 USE_GL_FUNC(glDeleteSync)
2878 USE_GL_FUNC(glFenceSync)
2879 USE_GL_FUNC(glGetInteger64v)
2880 USE_GL_FUNC(glGetSynciv)
2881 USE_GL_FUNC(glIsSync)
2882 USE_GL_FUNC(glWaitSync)
2883 /* GL_ARB_tessellation_shader */
2884 USE_GL_FUNC(glPatchParameteri)
2885 USE_GL_FUNC(glPatchParameterfv)
2886 /* GL_ARB_texture_buffer_object */
2887 USE_GL_FUNC(glTexBufferARB)
2888 /* GL_ARB_texture_buffer_range */
2889 USE_GL_FUNC(glTexBufferRange)
2890 /* GL_ARB_texture_compression */
2891 USE_GL_FUNC(glCompressedTexImage2DARB)
2892 USE_GL_FUNC(glCompressedTexImage3DARB)
2893 USE_GL_FUNC(glCompressedTexSubImage2DARB)
2894 USE_GL_FUNC(glCompressedTexSubImage3DARB)
2895 USE_GL_FUNC(glGetCompressedTexImageARB)
2896 /* GL_ARB_texture_multisample */
2897 USE_GL_FUNC(glGetMultisamplefv);
2898 USE_GL_FUNC(glSampleMaski);
2899 USE_GL_FUNC(glTexImage2DMultisample);
2900 USE_GL_FUNC(glTexImage3DMultisample);
2901 /* GL_ARB_texture_storage */
2902 USE_GL_FUNC(glTexStorage1D)
2903 USE_GL_FUNC(glTexStorage2D)
2904 USE_GL_FUNC(glTexStorage3D)
2905 /* GL_ARB_texture_storage_multisample */
2906 USE_GL_FUNC(glTexStorage2DMultisample);
2907 USE_GL_FUNC(glTexStorage3DMultisample);
2908 /* GL_ARB_texture_view */
2909 USE_GL_FUNC(glTextureView)
2910 /* GL_ARB_timer_query */
2911 USE_GL_FUNC(glQueryCounter)
2912 USE_GL_FUNC(glGetQueryObjectui64v)
2913 /* GL_ARB_transform_feedback2 */
2914 USE_GL_FUNC(glBindTransformFeedback);
2915 USE_GL_FUNC(glDeleteTransformFeedbacks);
2916 USE_GL_FUNC(glDrawTransformFeedback);
2917 USE_GL_FUNC(glGenTransformFeedbacks);
2918 USE_GL_FUNC(glIsTransformFeedback);
2919 USE_GL_FUNC(glPauseTransformFeedback);
2920 USE_GL_FUNC(glResumeTransformFeedback);
2921 /* GL_ARB_transform_feedback3 */
2922 USE_GL_FUNC(glBeginQueryIndexed);
2923 USE_GL_FUNC(glDrawTransformFeedbackStream);
2924 USE_GL_FUNC(glEndQueryIndexed);
2925 USE_GL_FUNC(glGetQueryIndexediv);
2926 /* GL_ARB_uniform_buffer_object */
2927 USE_GL_FUNC(glBindBufferBase)
2928 USE_GL_FUNC(glBindBufferRange)
2929 USE_GL_FUNC(glGetActiveUniformBlockName)
2930 USE_GL_FUNC(glGetActiveUniformBlockiv)
2931 USE_GL_FUNC(glGetActiveUniformName)
2932 USE_GL_FUNC(glGetActiveUniformsiv)
2933 USE_GL_FUNC(glGetIntegeri_v)
2934 USE_GL_FUNC(glGetUniformBlockIndex)
2935 USE_GL_FUNC(glGetUniformIndices)
2936 USE_GL_FUNC(glUniformBlockBinding)
2937 /* GL_ARB_vertex_buffer_object */
2938 USE_GL_FUNC(glBindBufferARB)
2939 USE_GL_FUNC(glBufferDataARB)
2940 USE_GL_FUNC(glBufferSubDataARB)
2941 USE_GL_FUNC(glDeleteBuffersARB)
2942 USE_GL_FUNC(glGenBuffersARB)
2943 USE_GL_FUNC(glGetBufferParameterivARB)
2944 USE_GL_FUNC(glGetBufferPointervARB)
2945 USE_GL_FUNC(glGetBufferSubDataARB)
2946 USE_GL_FUNC(glIsBufferARB)
2947 USE_GL_FUNC(glMapBufferARB)
2948 USE_GL_FUNC(glUnmapBufferARB)
2949 /* GL_ARB_vertex_program */
2950 USE_GL_FUNC(glBindProgramARB)
2951 USE_GL_FUNC(glDeleteProgramsARB)
2952 USE_GL_FUNC(glDisableVertexAttribArrayARB)
2953 USE_GL_FUNC(glEnableVertexAttribArrayARB)
2954 USE_GL_FUNC(glGenProgramsARB)
2955 USE_GL_FUNC(glGetProgramivARB)
2956 USE_GL_FUNC(glProgramEnvParameter4fvARB)
2957 USE_GL_FUNC(glProgramLocalParameter4fvARB)
2958 USE_GL_FUNC(glProgramStringARB)
2959 USE_GL_FUNC(glVertexAttrib1dARB)
2960 USE_GL_FUNC(glVertexAttrib1dvARB)
2961 USE_GL_FUNC(glVertexAttrib1fARB)
2962 USE_GL_FUNC(glVertexAttrib1fvARB)
2963 USE_GL_FUNC(glVertexAttrib1sARB)
2964 USE_GL_FUNC(glVertexAttrib1svARB)
2965 USE_GL_FUNC(glVertexAttrib2dARB)
2966 USE_GL_FUNC(glVertexAttrib2dvARB)
2967 USE_GL_FUNC(glVertexAttrib2fARB)
2968 USE_GL_FUNC(glVertexAttrib2fvARB)
2969 USE_GL_FUNC(glVertexAttrib2sARB)
2970 USE_GL_FUNC(glVertexAttrib2svARB)
2971 USE_GL_FUNC(glVertexAttrib3dARB)
2972 USE_GL_FUNC(glVertexAttrib3dvARB)
2973 USE_GL_FUNC(glVertexAttrib3fARB)
2974 USE_GL_FUNC(glVertexAttrib3fvARB)
2975 USE_GL_FUNC(glVertexAttrib3sARB)
2976 USE_GL_FUNC(glVertexAttrib3svARB)
2977 USE_GL_FUNC(glVertexAttrib4NbvARB)
2978 USE_GL_FUNC(glVertexAttrib4NivARB)
2979 USE_GL_FUNC(glVertexAttrib4NsvARB)
2980 USE_GL_FUNC(glVertexAttrib4NubARB)
2981 USE_GL_FUNC(glVertexAttrib4NubvARB)
2982 USE_GL_FUNC(glVertexAttrib4NuivARB)
2983 USE_GL_FUNC(glVertexAttrib4NusvARB)
2984 USE_GL_FUNC(glVertexAttrib4bvARB)
2985 USE_GL_FUNC(glVertexAttrib4dARB)
2986 USE_GL_FUNC(glVertexAttrib4dvARB)
2987 USE_GL_FUNC(glVertexAttrib4fARB)
2988 USE_GL_FUNC(glVertexAttrib4fvARB)
2989 USE_GL_FUNC(glVertexAttrib4ivARB)
2990 USE_GL_FUNC(glVertexAttrib4sARB)
2991 USE_GL_FUNC(glVertexAttrib4svARB)
2992 USE_GL_FUNC(glVertexAttrib4ubvARB)
2993 USE_GL_FUNC(glVertexAttrib4uivARB)
2994 USE_GL_FUNC(glVertexAttrib4usvARB)
2995 USE_GL_FUNC(glVertexAttribPointerARB)
2996 /* GL_ARB_viewport_array */
2997 USE_GL_FUNC(glDepthRangeArrayv)
2998 USE_GL_FUNC(glDepthRangeIndexed)
2999 USE_GL_FUNC(glGetDoublei_v)
3000 USE_GL_FUNC(glGetFloati_v)
3001 USE_GL_FUNC(glScissorArrayv)
3002 USE_GL_FUNC(glScissorIndexed)
3003 USE_GL_FUNC(glScissorIndexedv)
3004 USE_GL_FUNC(glViewportArrayv)
3005 USE_GL_FUNC(glViewportIndexedf)
3006 USE_GL_FUNC(glViewportIndexedfv)
3007 /* GL_ATI_fragment_shader */
3008 USE_GL_FUNC(glAlphaFragmentOp1ATI)
3009 USE_GL_FUNC(glAlphaFragmentOp2ATI)
3010 USE_GL_FUNC(glAlphaFragmentOp3ATI)
3011 USE_GL_FUNC(glBeginFragmentShaderATI)
3012 USE_GL_FUNC(glBindFragmentShaderATI)
3013 USE_GL_FUNC(glColorFragmentOp1ATI)
3014 USE_GL_FUNC(glColorFragmentOp2ATI)
3015 USE_GL_FUNC(glColorFragmentOp3ATI)
3016 USE_GL_FUNC(glDeleteFragmentShaderATI)
3017 USE_GL_FUNC(glEndFragmentShaderATI)
3018 USE_GL_FUNC(glGenFragmentShadersATI)
3019 USE_GL_FUNC(glPassTexCoordATI)
3020 USE_GL_FUNC(glSampleMapATI)
3021 USE_GL_FUNC(glSetFragmentShaderConstantATI)
3022 /* GL_ATI_separate_stencil */
3023 USE_GL_FUNC(glStencilOpSeparateATI)
3024 USE_GL_FUNC(glStencilFuncSeparateATI)
3025 /* GL_EXT_blend_color */
3026 USE_GL_FUNC(glBlendColorEXT)
3027 /* GL_EXT_blend_equation_separate */
3028 USE_GL_FUNC(glBlendFuncSeparateEXT)
3029 /* GL_EXT_blend_func_separate */
3030 USE_GL_FUNC(glBlendEquationSeparateEXT)
3031 /* GL_EXT_blend_minmax */
3032 USE_GL_FUNC(glBlendEquationEXT)
3033 /* GL_EXT_depth_bounds_test */
3034 USE_GL_FUNC(glDepthBoundsEXT)
3035 /* GL_EXT_draw_buffers2 */
3036 USE_GL_FUNC(glColorMaskIndexedEXT)
3037 USE_GL_FUNC(glDisableIndexedEXT)
3038 USE_GL_FUNC(glEnableIndexedEXT)
3039 USE_GL_FUNC(glGetBooleanIndexedvEXT)
3040 USE_GL_FUNC(glGetIntegerIndexedvEXT)
3041 USE_GL_FUNC(glIsEnabledIndexedEXT)
3042 /* GL_EXT_fog_coord */
3043 USE_GL_FUNC(glFogCoordPointerEXT)
3044 USE_GL_FUNC(glFogCoorddEXT)
3045 USE_GL_FUNC(glFogCoorddvEXT)
3046 USE_GL_FUNC(glFogCoordfEXT)
3047 USE_GL_FUNC(glFogCoordfvEXT)
3048 /* GL_EXT_framebuffer_blit */
3049 USE_GL_FUNC(glBlitFramebufferEXT)
3050 /* GL_EXT_framebuffer_multisample */
3051 USE_GL_FUNC(glRenderbufferStorageMultisampleEXT)
3052 /* GL_EXT_framebuffer_object */
3053 USE_GL_FUNC(glBindFramebufferEXT)
3054 USE_GL_FUNC(glBindRenderbufferEXT)
3055 USE_GL_FUNC(glCheckFramebufferStatusEXT)
3056 USE_GL_FUNC(glDeleteFramebuffersEXT)
3057 USE_GL_FUNC(glDeleteRenderbuffersEXT)
3058 USE_GL_FUNC(glFramebufferRenderbufferEXT)
3059 USE_GL_FUNC(glFramebufferTexture1DEXT)
3060 USE_GL_FUNC(glFramebufferTexture2DEXT)
3061 USE_GL_FUNC(glFramebufferTexture3DEXT)
3062 USE_GL_FUNC(glGenFramebuffersEXT)
3063 USE_GL_FUNC(glGenRenderbuffersEXT)
3064 USE_GL_FUNC(glGenerateMipmapEXT)
3065 USE_GL_FUNC(glGetFramebufferAttachmentParameterivEXT)
3066 USE_GL_FUNC(glGetRenderbufferParameterivEXT)
3067 USE_GL_FUNC(glIsFramebufferEXT)
3068 USE_GL_FUNC(glIsRenderbufferEXT)
3069 USE_GL_FUNC(glRenderbufferStorageEXT)
3070 /* GL_EXT_gpu_program_parameters */
3071 USE_GL_FUNC(glProgramEnvParameters4fvEXT)
3072 USE_GL_FUNC(glProgramLocalParameters4fvEXT)
3073 /* GL_EXT_gpu_shader4 */
3074 USE_GL_FUNC(glBindFragDataLocationEXT)
3075 USE_GL_FUNC(glGetFragDataLocationEXT)
3076 USE_GL_FUNC(glGetUniformuivEXT)
3077 USE_GL_FUNC(glGetVertexAttribIivEXT)
3078 USE_GL_FUNC(glGetVertexAttribIuivEXT)
3079 USE_GL_FUNC(glUniform1uiEXT)
3080 USE_GL_FUNC(glUniform1uivEXT)
3081 USE_GL_FUNC(glUniform2uiEXT)
3082 USE_GL_FUNC(glUniform2uivEXT)
3083 USE_GL_FUNC(glUniform3uiEXT)
3084 USE_GL_FUNC(glUniform3uivEXT)
3085 USE_GL_FUNC(glUniform4uiEXT)
3086 USE_GL_FUNC(glUniform4uivEXT)
3087 USE_GL_FUNC(glVertexAttribI1iEXT)
3088 USE_GL_FUNC(glVertexAttribI1ivEXT)
3089 USE_GL_FUNC(glVertexAttribI1uiEXT)
3090 USE_GL_FUNC(glVertexAttribI1uivEXT)
3091 USE_GL_FUNC(glVertexAttribI2iEXT)
3092 USE_GL_FUNC(glVertexAttribI2ivEXT)
3093 USE_GL_FUNC(glVertexAttribI2uiEXT)
3094 USE_GL_FUNC(glVertexAttribI2uivEXT)
3095 USE_GL_FUNC(glVertexAttribI3iEXT)
3096 USE_GL_FUNC(glVertexAttribI3ivEXT)
3097 USE_GL_FUNC(glVertexAttribI3uiEXT)
3098 USE_GL_FUNC(glVertexAttribI3uivEXT)
3099 USE_GL_FUNC(glVertexAttribI4bvEXT)
3100 USE_GL_FUNC(glVertexAttribI4iEXT)
3101 USE_GL_FUNC(glVertexAttribI4ivEXT)
3102 USE_GL_FUNC(glVertexAttribI4svEXT)
3103 USE_GL_FUNC(glVertexAttribI4ubvEXT)
3104 USE_GL_FUNC(glVertexAttribI4uiEXT)
3105 USE_GL_FUNC(glVertexAttribI4uivEXT)
3106 USE_GL_FUNC(glVertexAttribI4usvEXT)
3107 USE_GL_FUNC(glVertexAttribIPointerEXT)
3108 /* GL_EXT_point_parameters */
3109 USE_GL_FUNC(glPointParameterfEXT)
3110 USE_GL_FUNC(glPointParameterfvEXT)
3111 /* GL_EXT_provoking_vertex */
3112 USE_GL_FUNC(glProvokingVertexEXT)
3113 /* GL_EXT_secondary_color */
3114 USE_GL_FUNC(glSecondaryColor3fEXT)
3115 USE_GL_FUNC(glSecondaryColor3fvEXT)
3116 USE_GL_FUNC(glSecondaryColor3ubEXT)
3117 USE_GL_FUNC(glSecondaryColor3ubvEXT)
3118 USE_GL_FUNC(glSecondaryColorPointerEXT)
3119 /* GL_EXT_stencil_two_side */
3120 USE_GL_FUNC(glActiveStencilFaceEXT)
3121 /* GL_EXT_texture3D */
3122 USE_GL_FUNC(glTexImage3D)
3123 USE_GL_FUNC(glTexImage3DEXT)
3124 USE_GL_FUNC(glTexSubImage3D)
3125 USE_GL_FUNC(glTexSubImage3DEXT)
3126 /* GL_NV_fence */
3127 USE_GL_FUNC(glDeleteFencesNV)
3128 USE_GL_FUNC(glFinishFenceNV)
3129 USE_GL_FUNC(glGenFencesNV)
3130 USE_GL_FUNC(glGetFenceivNV)
3131 USE_GL_FUNC(glIsFenceNV)
3132 USE_GL_FUNC(glSetFenceNV)
3133 USE_GL_FUNC(glTestFenceNV)
3134 /* GL_NV_half_float */
3135 USE_GL_FUNC(glColor3hNV)
3136 USE_GL_FUNC(glColor3hvNV)
3137 USE_GL_FUNC(glColor4hNV)
3138 USE_GL_FUNC(glColor4hvNV)
3139 USE_GL_FUNC(glFogCoordhNV)
3140 USE_GL_FUNC(glFogCoordhvNV)
3141 USE_GL_FUNC(glMultiTexCoord1hNV)
3142 USE_GL_FUNC(glMultiTexCoord1hvNV)
3143 USE_GL_FUNC(glMultiTexCoord2hNV)
3144 USE_GL_FUNC(glMultiTexCoord2hvNV)
3145 USE_GL_FUNC(glMultiTexCoord3hNV)
3146 USE_GL_FUNC(glMultiTexCoord3hvNV)
3147 USE_GL_FUNC(glMultiTexCoord4hNV)
3148 USE_GL_FUNC(glMultiTexCoord4hvNV)
3149 USE_GL_FUNC(glNormal3hNV)
3150 USE_GL_FUNC(glNormal3hvNV)
3151 USE_GL_FUNC(glSecondaryColor3hNV)
3152 USE_GL_FUNC(glSecondaryColor3hvNV)
3153 USE_GL_FUNC(glTexCoord1hNV)
3154 USE_GL_FUNC(glTexCoord1hvNV)
3155 USE_GL_FUNC(glTexCoord2hNV)
3156 USE_GL_FUNC(glTexCoord2hvNV)
3157 USE_GL_FUNC(glTexCoord3hNV)
3158 USE_GL_FUNC(glTexCoord3hvNV)
3159 USE_GL_FUNC(glTexCoord4hNV)
3160 USE_GL_FUNC(glTexCoord4hvNV)
3161 USE_GL_FUNC(glVertex2hNV)
3162 USE_GL_FUNC(glVertex2hvNV)
3163 USE_GL_FUNC(glVertex3hNV)
3164 USE_GL_FUNC(glVertex3hvNV)
3165 USE_GL_FUNC(glVertex4hNV)
3166 USE_GL_FUNC(glVertex4hvNV)
3167 USE_GL_FUNC(glVertexAttrib1hNV)
3168 USE_GL_FUNC(glVertexAttrib1hvNV)
3169 USE_GL_FUNC(glVertexAttrib2hNV)
3170 USE_GL_FUNC(glVertexAttrib2hvNV)
3171 USE_GL_FUNC(glVertexAttrib3hNV)
3172 USE_GL_FUNC(glVertexAttrib3hvNV)
3173 USE_GL_FUNC(glVertexAttrib4hNV)
3174 USE_GL_FUNC(glVertexAttrib4hvNV)
3175 USE_GL_FUNC(glVertexAttribs1hvNV)
3176 USE_GL_FUNC(glVertexAttribs2hvNV)
3177 USE_GL_FUNC(glVertexAttribs3hvNV)
3178 USE_GL_FUNC(glVertexAttribs4hvNV)
3179 USE_GL_FUNC(glVertexWeighthNV)
3180 USE_GL_FUNC(glVertexWeighthvNV)
3181 /* GL_NV_point_sprite */
3182 USE_GL_FUNC(glPointParameteriNV)
3183 USE_GL_FUNC(glPointParameterivNV)
3184 /* GL_NV_register_combiners */
3185 USE_GL_FUNC(glCombinerInputNV)
3186 USE_GL_FUNC(glCombinerOutputNV)
3187 USE_GL_FUNC(glCombinerParameterfNV)
3188 USE_GL_FUNC(glCombinerParameterfvNV)
3189 USE_GL_FUNC(glCombinerParameteriNV)
3190 USE_GL_FUNC(glCombinerParameterivNV)
3191 USE_GL_FUNC(glFinalCombinerInputNV)
3192 /* WGL extensions */
3193 USE_GL_FUNC(wglChoosePixelFormatARB)
3194 USE_GL_FUNC(wglGetExtensionsStringARB)
3195 USE_GL_FUNC(wglGetPixelFormatAttribfvARB)
3196 USE_GL_FUNC(wglGetPixelFormatAttribivARB)
3197 USE_GL_FUNC(wglQueryCurrentRendererIntegerWINE)
3198 USE_GL_FUNC(wglQueryCurrentRendererStringWINE)
3199 USE_GL_FUNC(wglQueryRendererIntegerWINE)
3200 USE_GL_FUNC(wglQueryRendererStringWINE)
3201 USE_GL_FUNC(wglSetPixelFormatWINE)
3202 USE_GL_FUNC(wglSwapIntervalEXT)
3204 /* Newer core functions */
3205 USE_GL_FUNC(glActiveTexture) /* OpenGL 1.3 */
3206 USE_GL_FUNC(glAttachShader) /* OpenGL 2.0 */
3207 USE_GL_FUNC(glBeginQuery) /* OpenGL 1.5 */
3208 USE_GL_FUNC(glBeginTransformFeedback) /* OpenGL 3.0 */
3209 USE_GL_FUNC(glBindAttribLocation) /* OpenGL 2.0 */
3210 USE_GL_FUNC(glBindBuffer) /* OpenGL 1.5 */
3211 USE_GL_FUNC(glBindFragDataLocation) /* OpenGL 3.0 */
3212 USE_GL_FUNC(glBindVertexArray) /* OpenGL 3.0 */
3213 USE_GL_FUNC(glBlendColor) /* OpenGL 1.4 */
3214 USE_GL_FUNC(glBlendEquation) /* OpenGL 1.4 */
3215 USE_GL_FUNC(glBlendEquationSeparate) /* OpenGL 2.0 */
3216 USE_GL_FUNC(glBlendFuncSeparate) /* OpenGL 1.4 */
3217 USE_GL_FUNC(glBufferData) /* OpenGL 1.5 */
3218 USE_GL_FUNC(glBufferSubData) /* OpenGL 1.5 */
3219 USE_GL_FUNC(glColorMaski) /* OpenGL 3.0 */
3220 USE_GL_FUNC(glCompileShader) /* OpenGL 2.0 */
3221 USE_GL_FUNC(glCompressedTexImage2D) /* OpenGL 1.3 */
3222 USE_GL_FUNC(glCompressedTexImage3D) /* OpenGL 1.3 */
3223 USE_GL_FUNC(glCompressedTexSubImage2D) /* OpenGL 1.3 */
3224 USE_GL_FUNC(glCompressedTexSubImage3D) /* OpenGL 1.3 */
3225 USE_GL_FUNC(glCreateProgram) /* OpenGL 2.0 */
3226 USE_GL_FUNC(glCreateShader) /* OpenGL 2.0 */
3227 USE_GL_FUNC(glDebugMessageCallback) /* OpenGL 4.3 */
3228 USE_GL_FUNC(glDebugMessageControl) /* OpenGL 4.3 */
3229 USE_GL_FUNC(glDebugMessageInsert) /* OpenGL 4.3 */
3230 USE_GL_FUNC(glDeleteBuffers) /* OpenGL 1.5 */
3231 USE_GL_FUNC(glDeleteProgram) /* OpenGL 2.0 */
3232 USE_GL_FUNC(glDeleteQueries) /* OpenGL 1.5 */
3233 USE_GL_FUNC(glDeleteShader) /* OpenGL 2.0 */
3234 USE_GL_FUNC(glDeleteVertexArrays) /* OpenGL 3.0 */
3235 USE_GL_FUNC(glDetachShader) /* OpenGL 2.0 */
3236 USE_GL_FUNC(glDisablei) /* OpenGL 3.0 */
3237 USE_GL_FUNC(glDisableVertexAttribArray) /* OpenGL 2.0 */
3238 USE_GL_FUNC(glDrawArraysInstanced) /* OpenGL 3.1 */
3239 USE_GL_FUNC(glDrawBuffers) /* OpenGL 2.0 */
3240 USE_GL_FUNC(glDrawElementsInstanced) /* OpenGL 3.1 */
3241 USE_GL_FUNC(glEnablei) /* OpenGL 3.0 */
3242 USE_GL_FUNC(glEnableVertexAttribArray) /* OpenGL 2.0 */
3243 USE_GL_FUNC(glEndQuery) /* OpenGL 1.5 */
3244 USE_GL_FUNC(glEndTransformFeedback) /* OpenGL 3.0 */
3245 USE_GL_FUNC(glFramebufferTexture) /* OpenGL 3.2 */
3246 USE_GL_FUNC(glGenBuffers) /* OpenGL 1.5 */
3247 USE_GL_FUNC(glGenQueries) /* OpenGL 1.5 */
3248 USE_GL_FUNC(glGenVertexArrays) /* OpenGL 3.0 */
3249 USE_GL_FUNC(glGetActiveUniform) /* OpenGL 2.0 */
3250 USE_GL_FUNC(glGetAttachedShaders) /* OpenGL 2.0 */
3251 USE_GL_FUNC(glGetAttribLocation) /* OpenGL 2.0 */
3252 USE_GL_FUNC(glGetBooleani_v) /* OpenGL 3.0 */
3253 USE_GL_FUNC(glGetBufferSubData) /* OpenGL 1.5 */
3254 USE_GL_FUNC(glGetCompressedTexImage) /* OpenGL 1.3 */
3255 USE_GL_FUNC(glGetDebugMessageLog) /* OpenGL 4.3 */
3256 USE_GL_FUNC(glGetIntegeri_v) /* OpenGL 3.0 */
3257 USE_GL_FUNC(glGetProgramInfoLog) /* OpenGL 2.0 */
3258 USE_GL_FUNC(glGetProgramiv) /* OpenGL 2.0 */
3259 USE_GL_FUNC(glGetQueryiv) /* OpenGL 1.5 */
3260 USE_GL_FUNC(glGetQueryObjectuiv) /* OpenGL 1.5 */
3261 USE_GL_FUNC(glGetShaderInfoLog) /* OpenGL 2.0 */
3262 USE_GL_FUNC(glGetShaderiv) /* OpenGL 2.0 */
3263 USE_GL_FUNC(glGetShaderSource) /* OpenGL 2.0 */
3264 USE_GL_FUNC(glGetStringi) /* OpenGL 3.0 */
3265 USE_GL_FUNC(glGetTextureLevelParameteriv) /* OpenGL 4.5 */
3266 USE_GL_FUNC(glGetTextureParameteriv) /* OpenGL 4.5 */
3267 USE_GL_FUNC(glGetUniformfv) /* OpenGL 2.0 */
3268 USE_GL_FUNC(glGetUniformiv) /* OpenGL 2.0 */
3269 USE_GL_FUNC(glGetUniformLocation) /* OpenGL 2.0 */
3270 USE_GL_FUNC(glIsEnabledi) /* OpenGL 3.0 */
3271 USE_GL_FUNC(glLinkProgram) /* OpenGL 2.0 */
3272 USE_GL_FUNC(glMapBuffer) /* OpenGL 1.5 */
3273 USE_GL_FUNC(glPointParameteri) /* OpenGL 1.4 */
3274 USE_GL_FUNC(glPointParameteriv) /* OpenGL 1.4 */
3275 USE_GL_FUNC(glShaderSource) /* OpenGL 2.0 */
3276 USE_GL_FUNC(glStencilFuncSeparate) /* OpenGL 2.0 */
3277 USE_GL_FUNC(glStencilOpSeparate) /* OpenGL 2.0 */
3278 USE_GL_FUNC(glTexBuffer) /* OpenGL 3.1 */
3279 USE_GL_FUNC(glTexImage3D) /* OpenGL 1.2 */
3280 USE_GL_FUNC(glTexSubImage3D) /* OpenGL 1.2 */
3281 USE_GL_FUNC(glTransformFeedbackVaryings) /* OpenGL 3.0 */
3282 USE_GL_FUNC(glUniform1f) /* OpenGL 2.0 */
3283 USE_GL_FUNC(glUniform1fv) /* OpenGL 2.0 */
3284 USE_GL_FUNC(glUniform1i) /* OpenGL 2.0 */
3285 USE_GL_FUNC(glUniform1iv) /* OpenGL 2.0 */
3286 USE_GL_FUNC(glUniform2f) /* OpenGL 2.0 */
3287 USE_GL_FUNC(glUniform2fv) /* OpenGL 2.0 */
3288 USE_GL_FUNC(glUniform2i) /* OpenGL 2.0 */
3289 USE_GL_FUNC(glUniform2iv) /* OpenGL 2.0 */
3290 USE_GL_FUNC(glUniform3f) /* OpenGL 2.0 */
3291 USE_GL_FUNC(glUniform3fv) /* OpenGL 2.0 */
3292 USE_GL_FUNC(glUniform3i) /* OpenGL 2.0 */
3293 USE_GL_FUNC(glUniform3iv) /* OpenGL 2.0 */
3294 USE_GL_FUNC(glUniform4f) /* OpenGL 2.0 */
3295 USE_GL_FUNC(glUniform4fv) /* OpenGL 2.0 */
3296 USE_GL_FUNC(glUniform4i) /* OpenGL 2.0 */
3297 USE_GL_FUNC(glUniform4iv) /* OpenGL 2.0 */
3298 USE_GL_FUNC(glUniformMatrix2fv) /* OpenGL 2.0 */
3299 USE_GL_FUNC(glUniformMatrix3fv) /* OpenGL 2.0 */
3300 USE_GL_FUNC(glUniformMatrix4fv) /* OpenGL 2.0 */
3301 USE_GL_FUNC(glUnmapBuffer) /* OpenGL 1.5 */
3302 USE_GL_FUNC(glUseProgram) /* OpenGL 2.0 */
3303 USE_GL_FUNC(glValidateProgram) /* OpenGL 2.0 */
3304 USE_GL_FUNC(glVertexAttrib1f) /* OpenGL 2.0 */
3305 USE_GL_FUNC(glVertexAttrib1fv) /* OpenGL 2.0 */
3306 USE_GL_FUNC(glVertexAttrib2f) /* OpenGL 2.0 */
3307 USE_GL_FUNC(glVertexAttrib2fv) /* OpenGL 2.0 */
3308 USE_GL_FUNC(glVertexAttrib3f) /* OpenGL 2.0 */
3309 USE_GL_FUNC(glVertexAttrib3fv) /* OpenGL 2.0 */
3310 USE_GL_FUNC(glVertexAttrib4f) /* OpenGL 2.0 */
3311 USE_GL_FUNC(glVertexAttrib4fv) /* OpenGL 2.0 */
3312 USE_GL_FUNC(glVertexAttrib4Nsv) /* OpenGL 2.0 */
3313 USE_GL_FUNC(glVertexAttrib4Nub) /* OpenGL 2.0 */
3314 USE_GL_FUNC(glVertexAttrib4Nubv) /* OpenGL 2.0 */
3315 USE_GL_FUNC(glVertexAttrib4Nusv) /* OpenGL 2.0 */
3316 USE_GL_FUNC(glVertexAttrib4sv) /* OpenGL 2.0 */
3317 USE_GL_FUNC(glVertexAttrib4ubv) /* OpenGL 2.0 */
3318 USE_GL_FUNC(glVertexAttribDivisor) /* OpenGL 3.3 */
3319 USE_GL_FUNC(glVertexAttribIPointer) /* OpenGL 3.0 */
3320 USE_GL_FUNC(glVertexAttribPointer) /* OpenGL 2.0 */
3321 #undef USE_GL_FUNC
3323 #ifndef USE_WIN32_OPENGL
3324 /* hack: use the functions directly from the TEB table to bypass the thunks */
3325 /* note that we still need the above wglGetProcAddress calls to initialize the table */
3326 gl_info->gl_ops.ext = ((struct opengl_funcs *)NtCurrentTeb()->glTable)->ext;
3327 #endif
3329 #define MAP_GL_FUNCTION(core_func, ext_func) \
3330 do \
3332 if (!gl_info->gl_ops.ext.p_##core_func) \
3333 gl_info->gl_ops.ext.p_##core_func = gl_info->gl_ops.ext.p_##ext_func; \
3334 } while (0)
3335 #define MAP_GL_FUNCTION_CAST(core_func, ext_func) \
3336 do \
3338 if (!gl_info->gl_ops.ext.p_##core_func) \
3339 gl_info->gl_ops.ext.p_##core_func = (void *)gl_info->gl_ops.ext.p_##ext_func; \
3340 } while (0)
3342 MAP_GL_FUNCTION(glActiveTexture, glActiveTextureARB);
3343 MAP_GL_FUNCTION(glAttachShader, glAttachObjectARB);
3344 MAP_GL_FUNCTION(glBeginQuery, glBeginQueryARB);
3345 MAP_GL_FUNCTION(glBindAttribLocation, glBindAttribLocationARB);
3346 MAP_GL_FUNCTION(glBindBuffer, glBindBufferARB);
3347 MAP_GL_FUNCTION(glBindFragDataLocation, glBindFragDataLocationEXT);
3348 MAP_GL_FUNCTION(glBlendColor, glBlendColorEXT);
3349 MAP_GL_FUNCTION(glBlendEquation, glBlendEquationEXT);
3350 MAP_GL_FUNCTION(glBlendEquationSeparate, glBlendEquationSeparateEXT);
3351 MAP_GL_FUNCTION(glBlendFuncSeparate, glBlendFuncSeparateEXT);
3352 MAP_GL_FUNCTION(glBufferData, glBufferDataARB);
3353 MAP_GL_FUNCTION(glBufferSubData, glBufferSubDataARB);
3354 MAP_GL_FUNCTION(glColorMaski, glColorMaskIndexedEXT);
3355 MAP_GL_FUNCTION(glCompileShader, glCompileShaderARB);
3356 MAP_GL_FUNCTION(glCompressedTexImage2D, glCompressedTexImage2DARB);
3357 MAP_GL_FUNCTION(glCompressedTexImage3D, glCompressedTexImage3DARB);
3358 MAP_GL_FUNCTION(glCompressedTexSubImage2D, glCompressedTexSubImage2DARB);
3359 MAP_GL_FUNCTION(glCompressedTexSubImage3D, glCompressedTexSubImage3DARB);
3360 MAP_GL_FUNCTION(glCreateProgram, glCreateProgramObjectARB);
3361 MAP_GL_FUNCTION(glCreateShader, glCreateShaderObjectARB);
3362 MAP_GL_FUNCTION(glDebugMessageCallback, glDebugMessageCallbackARB);
3363 MAP_GL_FUNCTION(glDebugMessageControl, glDebugMessageControlARB);
3364 MAP_GL_FUNCTION(glDebugMessageInsert, glDebugMessageInsertARB);
3365 MAP_GL_FUNCTION(glDeleteBuffers, glDeleteBuffersARB);
3366 MAP_GL_FUNCTION(glDeleteProgram, glDeleteObjectARB);
3367 MAP_GL_FUNCTION(glDeleteQueries, glDeleteQueriesARB);
3368 MAP_GL_FUNCTION(glDeleteShader, glDeleteObjectARB);
3369 MAP_GL_FUNCTION(glDetachShader, glDetachObjectARB);
3370 MAP_GL_FUNCTION(glDisablei, glDisableIndexedEXT);
3371 MAP_GL_FUNCTION(glDisableVertexAttribArray, glDisableVertexAttribArrayARB);
3372 MAP_GL_FUNCTION(glDrawArraysInstanced, glDrawArraysInstancedARB);
3373 MAP_GL_FUNCTION(glDrawBuffers, glDrawBuffersARB);
3374 MAP_GL_FUNCTION(glDrawElementsInstanced, glDrawElementsInstancedARB);
3375 MAP_GL_FUNCTION(glEnablei, glEnableIndexedEXT);
3376 MAP_GL_FUNCTION(glEnableVertexAttribArray, glEnableVertexAttribArrayARB);
3377 MAP_GL_FUNCTION(glEndQuery, glEndQueryARB);
3378 MAP_GL_FUNCTION(glFramebufferTexture, glFramebufferTextureARB);
3379 MAP_GL_FUNCTION(glGenBuffers, glGenBuffersARB);
3380 MAP_GL_FUNCTION(glGenQueries, glGenQueriesARB);
3381 MAP_GL_FUNCTION(glGetActiveUniform, glGetActiveUniformARB);
3382 MAP_GL_FUNCTION(glGetAttachedShaders, glGetAttachedObjectsARB);
3383 MAP_GL_FUNCTION(glGetAttribLocation, glGetAttribLocationARB);
3384 MAP_GL_FUNCTION(glGetBooleani_v, glGetBooleanIndexedvEXT);
3385 MAP_GL_FUNCTION(glGetBufferSubData, glGetBufferSubDataARB);
3386 MAP_GL_FUNCTION(glGetCompressedTexImage, glGetCompressedTexImageARB);
3387 MAP_GL_FUNCTION(glGetDebugMessageLog, glGetDebugMessageLogARB);
3388 MAP_GL_FUNCTION(glGetIntegeri_v, glGetIntegerIndexedvEXT);
3389 MAP_GL_FUNCTION(glGetProgramInfoLog, glGetInfoLogARB);
3390 MAP_GL_FUNCTION(glGetProgramiv, glGetObjectParameterivARB);
3391 MAP_GL_FUNCTION(glGetQueryiv, glGetQueryivARB);
3392 MAP_GL_FUNCTION(glGetQueryObjectuiv, glGetQueryObjectuivARB);
3393 MAP_GL_FUNCTION(glGetShaderInfoLog, glGetInfoLogARB);
3394 MAP_GL_FUNCTION(glGetShaderiv, glGetObjectParameterivARB);
3395 MAP_GL_FUNCTION(glGetShaderSource, glGetShaderSourceARB);
3396 MAP_GL_FUNCTION(glGetUniformfv, glGetUniformfvARB);
3397 MAP_GL_FUNCTION(glGetUniformiv, glGetUniformivARB);
3398 MAP_GL_FUNCTION(glGetUniformLocation, glGetUniformLocationARB);
3399 MAP_GL_FUNCTION(glIsEnabledi, glIsEnabledIndexedEXT);
3400 MAP_GL_FUNCTION(glLinkProgram, glLinkProgramARB);
3401 MAP_GL_FUNCTION(glMapBuffer, glMapBufferARB);
3402 MAP_GL_FUNCTION_CAST(glShaderSource, glShaderSourceARB);
3403 MAP_GL_FUNCTION(glTexBuffer, glTexBufferARB);
3404 MAP_GL_FUNCTION_CAST(glTexImage3D, glTexImage3DEXT);
3405 MAP_GL_FUNCTION(glTexSubImage3D, glTexSubImage3DEXT);
3406 MAP_GL_FUNCTION(glUniform1f, glUniform1fARB);
3407 MAP_GL_FUNCTION(glUniform1fv, glUniform1fvARB);
3408 MAP_GL_FUNCTION(glUniform1i, glUniform1iARB);
3409 MAP_GL_FUNCTION(glUniform1iv, glUniform1ivARB);
3410 MAP_GL_FUNCTION(glUniform2f, glUniform2fARB);
3411 MAP_GL_FUNCTION(glUniform2fv, glUniform2fvARB);
3412 MAP_GL_FUNCTION(glUniform2i, glUniform2iARB);
3413 MAP_GL_FUNCTION(glUniform2iv, glUniform2ivARB);
3414 MAP_GL_FUNCTION(glUniform3f, glUniform3fARB);
3415 MAP_GL_FUNCTION(glUniform3fv, glUniform3fvARB);
3416 MAP_GL_FUNCTION(glUniform3i, glUniform3iARB);
3417 MAP_GL_FUNCTION(glUniform3iv, glUniform3ivARB);
3418 MAP_GL_FUNCTION(glUniform4f, glUniform4fARB);
3419 MAP_GL_FUNCTION(glUniform4fv, glUniform4fvARB);
3420 MAP_GL_FUNCTION(glUniform4i, glUniform4iARB);
3421 MAP_GL_FUNCTION(glUniform4iv, glUniform4ivARB);
3422 MAP_GL_FUNCTION(glUniformMatrix2fv, glUniformMatrix2fvARB);
3423 MAP_GL_FUNCTION(glUniformMatrix3fv, glUniformMatrix3fvARB);
3424 MAP_GL_FUNCTION(glUniformMatrix4fv, glUniformMatrix4fvARB);
3425 MAP_GL_FUNCTION(glUnmapBuffer, glUnmapBufferARB);
3426 MAP_GL_FUNCTION(glUseProgram, glUseProgramObjectARB);
3427 MAP_GL_FUNCTION(glValidateProgram, glValidateProgramARB);
3428 MAP_GL_FUNCTION(glVertexAttrib1f, glVertexAttrib1fARB);
3429 MAP_GL_FUNCTION(glVertexAttrib1fv, glVertexAttrib1fvARB);
3430 MAP_GL_FUNCTION(glVertexAttrib2f, glVertexAttrib2fARB);
3431 MAP_GL_FUNCTION(glVertexAttrib2fv, glVertexAttrib2fvARB);
3432 MAP_GL_FUNCTION(glVertexAttrib3f, glVertexAttrib3fARB);
3433 MAP_GL_FUNCTION(glVertexAttrib3fv, glVertexAttrib3fvARB);
3434 MAP_GL_FUNCTION(glVertexAttrib4f, glVertexAttrib4fARB);
3435 MAP_GL_FUNCTION(glVertexAttrib4fv, glVertexAttrib4fvARB);
3436 MAP_GL_FUNCTION(glVertexAttrib4Nsv, glVertexAttrib4NsvARB);
3437 MAP_GL_FUNCTION(glVertexAttrib4Nub, glVertexAttrib4NubARB);
3438 MAP_GL_FUNCTION(glVertexAttrib4Nubv, glVertexAttrib4NubvARB);
3439 MAP_GL_FUNCTION(glVertexAttrib4Nusv, glVertexAttrib4NusvARB);
3440 MAP_GL_FUNCTION(glVertexAttrib4sv, glVertexAttrib4svARB);
3441 MAP_GL_FUNCTION(glVertexAttrib4ubv, glVertexAttrib4ubvARB);
3442 MAP_GL_FUNCTION(glVertexAttribDivisor, glVertexAttribDivisorARB);
3443 MAP_GL_FUNCTION(glVertexAttribIPointer, glVertexAttribIPointerEXT);
3444 MAP_GL_FUNCTION(glVertexAttribPointer, glVertexAttribPointerARB);
3445 #undef MAP_GL_FUNCTION
3446 #undef MAP_GL_FUNCTION_CAST
3449 static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
3451 unsigned int i, sampler_count;
3452 GLfloat gl_floatv[2];
3453 GLint gl_max;
3455 gl_info->limits.buffers = 1;
3456 gl_info->limits.textures = 0;
3457 gl_info->limits.texture_coords = 0;
3458 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
3460 gl_info->limits.uniform_blocks[i] = 0;
3461 gl_info->limits.samplers[i] = 0;
3463 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = 1;
3464 gl_info->limits.combined_samplers = gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL];
3465 gl_info->limits.graphics_samplers = gl_info->limits.combined_samplers;
3466 gl_info->limits.vertex_attribs = 16;
3467 gl_info->limits.texture_buffer_offset_alignment = 1;
3468 gl_info->limits.glsl_vs_float_constants = 0;
3469 gl_info->limits.glsl_ps_float_constants = 0;
3470 gl_info->limits.arb_vs_float_constants = 0;
3471 gl_info->limits.arb_vs_native_constants = 0;
3472 gl_info->limits.arb_vs_instructions = 0;
3473 gl_info->limits.arb_vs_temps = 0;
3474 gl_info->limits.arb_ps_float_constants = 0;
3475 gl_info->limits.arb_ps_local_constants = 0;
3476 gl_info->limits.arb_ps_instructions = 0;
3477 gl_info->limits.arb_ps_temps = 0;
3479 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_CLIP_DISTANCES, &gl_max);
3480 gl_info->limits.user_clip_distances = min(MAX_CLIP_DISTANCES, gl_max);
3481 TRACE("Clip plane support - max planes %d.\n", gl_max);
3483 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3485 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
3486 gl_info->limits.lights = gl_max;
3487 TRACE("Light support - max lights %d.\n", gl_max);
3490 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max);
3491 gl_info->limits.texture_size = gl_max;
3492 TRACE("Maximum texture size support - max texture size %d.\n", gl_max);
3494 gl_info->gl_ops.gl.p_glGetFloatv(gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]
3495 ? GL_ALIASED_POINT_SIZE_RANGE : GL_POINT_SIZE_RANGE, gl_floatv);
3496 gl_info->limits.pointsize_min = gl_floatv[0];
3497 gl_info->limits.pointsize_max = gl_floatv[1];
3498 TRACE("Maximum point size support - max point size %f.\n", gl_floatv[1]);
3500 if (gl_info->supported[ARB_MAP_BUFFER_ALIGNMENT])
3502 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &gl_max);
3503 TRACE("Minimum buffer map alignment: %d.\n", gl_max);
3505 else
3507 WARN_(d3d_perf)("Driver doesn't guarantee a minimum buffer map alignment.\n");
3509 if (gl_info->supported[NV_REGISTER_COMBINERS])
3511 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max);
3512 gl_info->limits.general_combiners = gl_max;
3513 TRACE("Max general combiners: %d.\n", gl_max);
3515 if (gl_info->supported[ARB_DRAW_BUFFERS] && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
3517 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max);
3518 gl_info->limits.buffers = min(MAX_RENDER_TARGET_VIEWS, gl_max);
3519 TRACE("Max draw buffers: %u.\n", gl_max);
3521 if (gl_info->supported[ARB_MULTITEXTURE])
3523 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3525 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
3526 gl_info->limits.textures = min(MAX_TEXTURES, gl_max);
3527 TRACE("Max textures: %d.\n", gl_info->limits.textures);
3529 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
3531 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &gl_max);
3532 gl_info->limits.texture_coords = min(MAX_TEXTURES, gl_max);
3534 else
3536 gl_info->limits.texture_coords = gl_info->limits.textures;
3538 TRACE("Max texture coords: %d.\n", gl_info->limits.texture_coords);
3541 if (gl_info->supported[ARB_FRAGMENT_PROGRAM] || gl_info->supported[ARB_FRAGMENT_SHADER])
3543 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &gl_max);
3544 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = gl_max;
3546 else
3548 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = gl_info->limits.textures;
3550 TRACE("Max fragment samplers: %d.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL]);
3552 if (gl_info->supported[ARB_VERTEX_SHADER])
3554 unsigned int vertex_sampler_count;
3556 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &gl_max);
3557 vertex_sampler_count = gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX] = gl_max;
3558 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &gl_max);
3559 gl_info->limits.combined_samplers = gl_max;
3560 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &gl_max);
3561 gl_info->limits.vertex_attribs = gl_max;
3563 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
3564 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
3565 * an issue because then the sampler setup only depends on the two shaders. If a pixel
3566 * shader is used with fixed function vertex processing we're fine too because fixed function
3567 * vertex processing doesn't use any samplers. If fixed function fragment processing is
3568 * used we have to make sure that all vertex sampler setups are valid together with all
3569 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
3570 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
3571 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
3572 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
3573 * a fixed function pipeline anymore.
3575 * So this is just a check to check that our assumption holds true. If not, write a warning
3576 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
3577 if (vertex_sampler_count && gl_info->limits.combined_samplers < 12
3578 && MAX_TEXTURES + vertex_sampler_count > gl_info->limits.combined_samplers)
3580 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
3581 vertex_sampler_count, gl_info->limits.combined_samplers);
3582 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
3583 if (gl_info->limits.combined_samplers > MAX_TEXTURES)
3584 vertex_sampler_count = gl_info->limits.combined_samplers - MAX_TEXTURES;
3585 else
3586 vertex_sampler_count = 0;
3587 gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX] = vertex_sampler_count;
3590 else
3592 gl_info->limits.combined_samplers = gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL];
3594 TRACE("Max vertex samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX]);
3595 TRACE("Max combined samplers: %u.\n", gl_info->limits.combined_samplers);
3596 TRACE("Max vertex attributes: %u.\n", gl_info->limits.vertex_attribs);
3598 else
3600 gl_info->limits.textures = 1;
3601 gl_info->limits.texture_coords = 1;
3604 if (gl_info->supported[EXT_TEXTURE3D])
3606 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &gl_max);
3607 gl_info->limits.texture3d_size = gl_max;
3608 TRACE("Max texture3D size: %d.\n", gl_info->limits.texture3d_size);
3610 if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
3612 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &gl_max);
3613 gl_info->limits.anisotropy = gl_max;
3614 TRACE("Max anisotropy: %d.\n", gl_info->limits.anisotropy);
3616 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
3618 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
3619 gl_info->limits.arb_ps_float_constants = gl_max;
3620 TRACE("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info->limits.arb_ps_float_constants);
3621 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
3622 gl_info->limits.arb_ps_native_constants = gl_max;
3623 TRACE("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
3624 gl_info->limits.arb_ps_native_constants);
3625 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
3626 gl_info->limits.arb_ps_temps = gl_max;
3627 TRACE("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_ps_temps);
3628 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
3629 gl_info->limits.arb_ps_instructions = gl_max;
3630 TRACE("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info->limits.arb_ps_instructions);
3631 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &gl_max));
3632 gl_info->limits.arb_ps_local_constants = gl_max;
3633 TRACE("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info->limits.arb_ps_instructions);
3635 if (gl_info->supported[ARB_VERTEX_PROGRAM])
3637 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
3638 gl_info->limits.arb_vs_float_constants = gl_max;
3639 TRACE("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info->limits.arb_vs_float_constants);
3640 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
3641 gl_info->limits.arb_vs_native_constants = gl_max;
3642 TRACE("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
3643 gl_info->limits.arb_vs_native_constants);
3644 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
3645 gl_info->limits.arb_vs_temps = gl_max;
3646 TRACE("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_vs_temps);
3647 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
3648 gl_info->limits.arb_vs_instructions = gl_max;
3649 TRACE("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info->limits.arb_vs_instructions);
3651 if (gl_info->supported[ARB_VERTEX_SHADER])
3653 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &gl_max);
3654 gl_info->limits.glsl_vs_float_constants = gl_max / 4;
3655 TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info->limits.glsl_vs_float_constants);
3657 if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3659 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &gl_max);
3660 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_VERTEX] = min(gl_max, WINED3D_MAX_CBS);
3661 TRACE("Max vertex uniform blocks: %u (%d).\n",
3662 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_VERTEX], gl_max);
3665 if (gl_info->supported[ARB_TESSELLATION_SHADER])
3667 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS, &gl_max);
3668 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_HULL] = min(gl_max, WINED3D_MAX_CBS);
3669 TRACE("Max hull uniform blocks: %u (%d).\n",
3670 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_HULL], gl_max);
3671 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS, &gl_max);
3672 gl_info->limits.samplers[WINED3D_SHADER_TYPE_HULL] = gl_max;
3673 TRACE("Max hull samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_HULL]);
3675 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS, &gl_max);
3676 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_DOMAIN] = min(gl_max, WINED3D_MAX_CBS);
3677 TRACE("Max domain uniform blocks: %u (%d).\n",
3678 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_DOMAIN], gl_max);
3679 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS, &gl_max);
3680 gl_info->limits.samplers[WINED3D_SHADER_TYPE_DOMAIN] = gl_max;
3681 TRACE("Max domain samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_DOMAIN]);
3683 if (gl_info->supported[WINED3D_GL_VERSION_3_2] && gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3685 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GEOMETRY_UNIFORM_BLOCKS, &gl_max);
3686 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_GEOMETRY] = min(gl_max, WINED3D_MAX_CBS);
3687 TRACE("Max geometry uniform blocks: %u (%d).\n",
3688 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_GEOMETRY], gl_max);
3689 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, &gl_max);
3690 gl_info->limits.samplers[WINED3D_SHADER_TYPE_GEOMETRY] = gl_max;
3691 TRACE("Max geometry samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_GEOMETRY]);
3693 if (gl_info->supported[ARB_FRAGMENT_SHADER])
3695 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &gl_max);
3696 gl_info->limits.glsl_ps_float_constants = gl_max / 4;
3697 TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info->limits.glsl_ps_float_constants);
3698 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
3699 gl_info->limits.glsl_varyings = gl_max;
3700 TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
3702 if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3704 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &gl_max);
3705 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_PIXEL] = min(gl_max, WINED3D_MAX_CBS);
3706 TRACE("Max fragment uniform blocks: %u (%d).\n",
3707 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_PIXEL], gl_max);
3710 if (gl_info->supported[ARB_COMPUTE_SHADER])
3712 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMPUTE_UNIFORM_BLOCKS, &gl_max);
3713 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_COMPUTE] = min(gl_max, WINED3D_MAX_CBS);
3714 TRACE("Max compute uniform blocks: %u (%d).\n",
3715 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_COMPUTE], gl_max);
3716 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS, &gl_max);
3717 gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE] = gl_max;
3718 TRACE("Max compute samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE]);
3720 if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3722 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &gl_max);
3723 TRACE("Max combined uniform blocks: %d.\n", gl_max);
3724 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &gl_max);
3725 TRACE("Max uniform buffer bindings: %d.\n", gl_max);
3727 if (gl_info->supported[ARB_TEXTURE_BUFFER_RANGE])
3729 gl_info->gl_ops.gl.p_glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &gl_max);
3730 gl_info->limits.texture_buffer_offset_alignment = gl_max;
3731 TRACE("Minimum required texture buffer offset alignment %d.\n", gl_max);
3733 if (gl_info->supported[ARB_SHADER_ATOMIC_COUNTERS])
3735 GLint max_fragment_buffers, max_combined_buffers, max_bindings;
3736 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS, &max_fragment_buffers);
3737 TRACE("Max fragment atomic counter buffers: %d.\n", max_fragment_buffers);
3738 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS, &max_combined_buffers);
3739 TRACE("Max combined atomic counter buffers: %d.\n", max_combined_buffers);
3740 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &max_bindings);
3741 TRACE("Max atomic counter buffer bindings: %d.\n", max_bindings);
3742 if (max_fragment_buffers < MAX_UNORDERED_ACCESS_VIEWS
3743 || max_combined_buffers < MAX_UNORDERED_ACCESS_VIEWS
3744 || max_bindings < MAX_UNORDERED_ACCESS_VIEWS)
3746 WARN("Disabling ARB_shader_atomic_counters.\n");
3747 gl_info->supported[ARB_SHADER_ATOMIC_COUNTERS] = FALSE;
3750 if (gl_info->supported[ARB_TRANSFORM_FEEDBACK3])
3752 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_STREAMS, &gl_max);
3753 TRACE("Max vertex streams: %d.\n", gl_max);
3756 if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
3757 gl_info->gl_ops.gl.p_glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess);
3758 else
3759 gl_info->limits.shininess = 128.0f;
3761 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT] || gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
3763 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_SAMPLES, &gl_max);
3764 gl_info->limits.samples = gl_max;
3767 if (gl_info->supported[ARB_FRAMEBUFFER_NO_ATTACHMENTS])
3769 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAMEBUFFER_WIDTH, &gl_max);
3770 gl_info->limits.framebuffer_width = gl_max;
3771 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAMEBUFFER_HEIGHT, &gl_max);
3772 gl_info->limits.framebuffer_height = gl_max;
3774 else
3776 gl_info->limits.framebuffer_width = gl_info->limits.texture_size;
3777 gl_info->limits.framebuffer_height = gl_info->limits.texture_size;
3780 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] =
3781 min(gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL], MAX_GL_FRAGMENT_SAMPLERS);
3782 sampler_count = 0;
3783 for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
3784 sampler_count += gl_info->limits.samplers[i];
3785 if (gl_info->supported[WINED3D_GL_VERSION_3_2] && gl_info->limits.combined_samplers < sampler_count)
3787 /* The minimum value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS in OpenGL
3788 * 3.2 is 48 (16 per stage). When tessellation shaders are supported
3789 * the minimum value is increased to 80. */
3790 WARN("Graphics pipeline sampler count %u is greater than combined sampler count %u.\n",
3791 sampler_count, gl_info->limits.combined_samplers);
3792 for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
3793 gl_info->limits.samplers[i] = min(gl_info->limits.samplers[i], 16);
3796 /* A majority of OpenGL implementations allow us to statically partition
3797 * the set of texture bindings into six separate sets. */
3798 gl_info->limits.graphics_samplers = gl_info->limits.combined_samplers;
3799 sampler_count = 0;
3800 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
3801 sampler_count += gl_info->limits.samplers[i];
3802 if (gl_info->limits.combined_samplers >= sampler_count)
3803 gl_info->limits.graphics_samplers -= gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE];
3806 /* Context activation is done by the caller. */
3807 static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
3808 struct wined3d_caps_gl_ctx *caps_gl_ctx, DWORD wined3d_creation_flags)
3810 static const struct
3812 enum wined3d_gl_extension extension;
3813 DWORD min_gl_version;
3815 core_extensions[] =
3817 {EXT_TEXTURE3D, MAKEDWORD_VERSION(1, 2)},
3818 {ARB_MULTISAMPLE, MAKEDWORD_VERSION(1, 3)},
3819 {ARB_MULTITEXTURE, MAKEDWORD_VERSION(1, 3)},
3820 {ARB_TEXTURE_BORDER_CLAMP, MAKEDWORD_VERSION(1, 3)},
3821 {ARB_TEXTURE_COMPRESSION, MAKEDWORD_VERSION(1, 3)},
3822 {ARB_TEXTURE_CUBE_MAP, MAKEDWORD_VERSION(1, 3)},
3823 {ARB_DEPTH_TEXTURE, MAKEDWORD_VERSION(1, 4)},
3824 {ARB_POINT_PARAMETERS, MAKEDWORD_VERSION(1, 4)},
3825 {ARB_SHADOW, MAKEDWORD_VERSION(1, 4)},
3826 {ARB_TEXTURE_MIRRORED_REPEAT, MAKEDWORD_VERSION(1, 4)},
3827 {EXT_BLEND_COLOR, MAKEDWORD_VERSION(1, 4)},
3828 {EXT_BLEND_FUNC_SEPARATE, MAKEDWORD_VERSION(1, 4)},
3829 {EXT_BLEND_MINMAX, MAKEDWORD_VERSION(1, 4)},
3830 {EXT_BLEND_SUBTRACT, MAKEDWORD_VERSION(1, 4)},
3831 {EXT_STENCIL_WRAP, MAKEDWORD_VERSION(1, 4)},
3832 {NV_POINT_SPRITE, MAKEDWORD_VERSION(1, 4)},
3833 {ARB_OCCLUSION_QUERY, MAKEDWORD_VERSION(1, 5)},
3834 {ARB_VERTEX_BUFFER_OBJECT, MAKEDWORD_VERSION(1, 5)},
3835 {ARB_DRAW_BUFFERS, MAKEDWORD_VERSION(2, 0)},
3836 {ARB_FRAGMENT_SHADER, MAKEDWORD_VERSION(2, 0)},
3837 {ARB_SHADING_LANGUAGE_100, MAKEDWORD_VERSION(2, 0)},
3838 {ARB_TEXTURE_NON_POWER_OF_TWO, MAKEDWORD_VERSION(2, 0)},
3839 {ARB_VERTEX_SHADER, MAKEDWORD_VERSION(2, 0)},
3840 {EXT_BLEND_EQUATION_SEPARATE, MAKEDWORD_VERSION(2, 0)},
3841 {ARB_PIXEL_BUFFER_OBJECT, MAKEDWORD_VERSION(2, 1)},
3842 {EXT_TEXTURE_SRGB, MAKEDWORD_VERSION(2, 1)},
3843 {ARB_COLOR_BUFFER_FLOAT, MAKEDWORD_VERSION(3, 0)},
3844 {ARB_DEPTH_BUFFER_FLOAT, MAKEDWORD_VERSION(3, 0)},
3845 {ARB_FRAMEBUFFER_OBJECT, MAKEDWORD_VERSION(3, 0)},
3846 {ARB_FRAMEBUFFER_SRGB, MAKEDWORD_VERSION(3, 0)},
3847 {ARB_HALF_FLOAT_PIXEL, MAKEDWORD_VERSION(3, 0)},
3848 {ARB_HALF_FLOAT_VERTEX, MAKEDWORD_VERSION(3, 0)},
3849 {ARB_MAP_BUFFER_RANGE, MAKEDWORD_VERSION(3, 0)},
3850 {ARB_TEXTURE_COMPRESSION_RGTC, MAKEDWORD_VERSION(3, 0)},
3851 {ARB_TEXTURE_FLOAT, MAKEDWORD_VERSION(3, 0)},
3852 {ARB_TEXTURE_RG, MAKEDWORD_VERSION(3, 0)},
3853 {EXT_DRAW_BUFFERS2, MAKEDWORD_VERSION(3, 0)},
3854 {EXT_PACKED_FLOAT, MAKEDWORD_VERSION(3, 0)},
3855 {EXT_TEXTURE_ARRAY, MAKEDWORD_VERSION(3, 0)},
3856 {EXT_TEXTURE_INTEGER, MAKEDWORD_VERSION(3, 0)},
3857 {EXT_TEXTURE_SHARED_EXPONENT, MAKEDWORD_VERSION(3, 0)},
3858 /* We don't want to enable EXT_GPU_SHADER4: even though similar
3859 * functionality is available in core GL 3.0 / GLSL 1.30, it's different
3860 * enough that reusing the same flag for the new features hurts more
3861 * than it helps. */
3862 /* EXT_framebuffer_object, EXT_framebuffer_blit,
3863 * EXT_framebuffer_multisample and EXT_packed_depth_stencil
3864 * are integrated into ARB_framebuffer_object. */
3866 {ARB_COPY_BUFFER, MAKEDWORD_VERSION(3, 1)},
3867 {ARB_DRAW_INSTANCED, MAKEDWORD_VERSION(3, 1)},
3868 {ARB_TEXTURE_BUFFER_OBJECT, MAKEDWORD_VERSION(3, 1)},
3869 {ARB_UNIFORM_BUFFER_OBJECT, MAKEDWORD_VERSION(3, 1)},
3870 {EXT_TEXTURE_SNORM, MAKEDWORD_VERSION(3, 1)},
3871 /* We don't need or want GL_ARB_texture_rectangle (core in 3.1). */
3873 {ARB_DRAW_ELEMENTS_BASE_VERTEX, MAKEDWORD_VERSION(3, 2)},
3874 /* ARB_geometry_shader4 exposes a somewhat different API compared to 3.2
3875 * core geometry shaders so it's not really correct to expose the
3876 * extension for core-only support. */
3877 {ARB_FRAGMENT_COORD_CONVENTIONS, MAKEDWORD_VERSION(3, 2)},
3878 {ARB_PROVOKING_VERTEX, MAKEDWORD_VERSION(3, 2)},
3879 {ARB_SEAMLESS_CUBE_MAP, MAKEDWORD_VERSION(3, 2)},
3880 {ARB_SYNC, MAKEDWORD_VERSION(3, 2)},
3881 {ARB_TEXTURE_MULTISAMPLE, MAKEDWORD_VERSION(3, 2)},
3882 {ARB_VERTEX_ARRAY_BGRA, MAKEDWORD_VERSION(3, 2)},
3884 {ARB_BLEND_FUNC_EXTENDED, MAKEDWORD_VERSION(3, 3)},
3885 {ARB_EXPLICIT_ATTRIB_LOCATION, MAKEDWORD_VERSION(3, 3)},
3886 {ARB_INSTANCED_ARRAYS, MAKEDWORD_VERSION(3, 3)},
3887 {ARB_SAMPLER_OBJECTS, MAKEDWORD_VERSION(3, 3)},
3888 {ARB_SHADER_BIT_ENCODING, MAKEDWORD_VERSION(3, 3)},
3889 {ARB_TEXTURE_RGB10_A2UI, MAKEDWORD_VERSION(3, 3)},
3890 {ARB_TEXTURE_SWIZZLE, MAKEDWORD_VERSION(3, 3)},
3891 {ARB_TIMER_QUERY, MAKEDWORD_VERSION(3, 3)},
3892 {ARB_VERTEX_TYPE_2_10_10_10_REV, MAKEDWORD_VERSION(3, 3)},
3894 {ARB_DRAW_INDIRECT, MAKEDWORD_VERSION(4, 0)},
3895 {ARB_GPU_SHADER5, MAKEDWORD_VERSION(4, 0)},
3896 {ARB_TESSELLATION_SHADER, MAKEDWORD_VERSION(4, 0)},
3897 {ARB_TEXTURE_CUBE_MAP_ARRAY, MAKEDWORD_VERSION(4, 0)},
3898 {ARB_TEXTURE_GATHER, MAKEDWORD_VERSION(4, 0)},
3899 {ARB_TRANSFORM_FEEDBACK2, MAKEDWORD_VERSION(4, 0)},
3900 {ARB_TRANSFORM_FEEDBACK3, MAKEDWORD_VERSION(4, 0)},
3902 {ARB_ES2_COMPATIBILITY, MAKEDWORD_VERSION(4, 1)},
3903 {ARB_VIEWPORT_ARRAY, MAKEDWORD_VERSION(4, 1)},
3905 {ARB_BASE_INSTANCE, MAKEDWORD_VERSION(4, 2)},
3906 {ARB_CONSERVATIVE_DEPTH, MAKEDWORD_VERSION(4, 2)},
3907 {ARB_INTERNALFORMAT_QUERY, MAKEDWORD_VERSION(4, 2)},
3908 {ARB_MAP_BUFFER_ALIGNMENT, MAKEDWORD_VERSION(4, 2)},
3909 {ARB_SHADER_ATOMIC_COUNTERS, MAKEDWORD_VERSION(4, 2)},
3910 {ARB_SHADER_IMAGE_LOAD_STORE, MAKEDWORD_VERSION(4, 2)},
3911 {ARB_SHADING_LANGUAGE_420PACK, MAKEDWORD_VERSION(4, 2)},
3912 {ARB_SHADING_LANGUAGE_PACKING, MAKEDWORD_VERSION(4, 2)},
3913 {ARB_TEXTURE_COMPRESSION_BPTC, MAKEDWORD_VERSION(4, 2)},
3914 {ARB_TEXTURE_STORAGE, MAKEDWORD_VERSION(4, 2)},
3916 {ARB_CLEAR_BUFFER_OBJECT, MAKEDWORD_VERSION(4, 3)},
3917 {ARB_COMPUTE_SHADER, MAKEDWORD_VERSION(4, 3)},
3918 {ARB_COPY_IMAGE, MAKEDWORD_VERSION(4, 3)},
3919 {ARB_DEBUG_OUTPUT, MAKEDWORD_VERSION(4, 3)},
3920 {ARB_ES3_COMPATIBILITY, MAKEDWORD_VERSION(4, 3)},
3921 {ARB_FRAGMENT_LAYER_VIEWPORT, MAKEDWORD_VERSION(4, 3)},
3922 {ARB_FRAMEBUFFER_NO_ATTACHMENTS, MAKEDWORD_VERSION(4, 3)},
3923 {ARB_INTERNALFORMAT_QUERY2, MAKEDWORD_VERSION(4, 3)},
3924 {ARB_SHADER_IMAGE_SIZE, MAKEDWORD_VERSION(4, 3)},
3925 {ARB_SHADER_STORAGE_BUFFER_OBJECT, MAKEDWORD_VERSION(4, 3)},
3926 {ARB_STENCIL_TEXTURING, MAKEDWORD_VERSION(4, 3)},
3927 {ARB_TEXTURE_BUFFER_RANGE, MAKEDWORD_VERSION(4, 3)},
3928 {ARB_TEXTURE_QUERY_LEVELS, MAKEDWORD_VERSION(4, 3)},
3929 {ARB_TEXTURE_STORAGE_MULTISAMPLE, MAKEDWORD_VERSION(4, 2)},
3930 {ARB_TEXTURE_VIEW, MAKEDWORD_VERSION(4, 3)},
3932 {ARB_CLEAR_TEXTURE, MAKEDWORD_VERSION(4, 4)},
3934 {ARB_CLIP_CONTROL, MAKEDWORD_VERSION(4, 5)},
3935 {ARB_CULL_DISTANCE, MAKEDWORD_VERSION(4, 5)},
3936 {ARB_DERIVATIVE_CONTROL, MAKEDWORD_VERSION(4, 5)},
3938 {ARB_PIPELINE_STATISTICS_QUERY, MAKEDWORD_VERSION(4, 6)},
3939 {ARB_TEXTURE_FILTER_ANISOTROPIC, MAKEDWORD_VERSION(4, 6)},
3941 struct wined3d_driver_info *driver_info = &adapter->driver_info;
3942 const char *gl_vendor_str, *gl_renderer_str, *gl_version_str;
3943 struct wined3d_gl_info *gl_info = &adapter->gl_info;
3944 const struct gpu_description *gpu_description;
3945 struct wined3d_vertex_caps vertex_caps;
3946 struct fragment_caps fragment_caps;
3947 struct shader_caps shader_caps;
3948 const char *WGL_Extensions = NULL;
3949 enum wined3d_gl_vendor gl_vendor;
3950 DWORD gl_version, gl_ext_emul_mask;
3951 UINT64 vram_bytes = 0;
3952 HDC hdc;
3953 unsigned int i, j;
3954 GLint context_profile = 0;
3956 TRACE("adapter %p.\n", adapter);
3958 gl_renderer_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER);
3959 TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str));
3960 if (!gl_renderer_str)
3962 ERR("Received a NULL GL_RENDERER.\n");
3963 return FALSE;
3966 gl_vendor_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VENDOR);
3967 TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str));
3968 if (!gl_vendor_str)
3970 ERR("Received a NULL GL_VENDOR.\n");
3971 return FALSE;
3974 /* Parse the GL_VERSION field into major and minor information */
3975 gl_version_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VERSION);
3976 TRACE("GL_VERSION: %s.\n", debugstr_a(gl_version_str));
3977 if (!gl_version_str)
3979 ERR("Received a NULL GL_VERSION.\n");
3980 return FALSE;
3982 gl_version = wined3d_parse_gl_version(gl_version_str);
3984 load_gl_funcs(gl_info);
3986 memset(gl_info->supported, 0, sizeof(gl_info->supported));
3987 gl_info->supported[WINED3D_GL_EXT_NONE] = TRUE;
3989 if (gl_version >= MAKEDWORD_VERSION(3, 2))
3991 gl_info->gl_ops.gl.p_glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &context_profile);
3992 checkGLcall("Querying context profile");
3994 if (context_profile & GL_CONTEXT_CORE_PROFILE_BIT)
3995 TRACE("Got a core profile context.\n");
3996 else
3997 gl_info->supported[WINED3D_GL_LEGACY_CONTEXT] = TRUE;
3999 TRACE("GL extensions reported:\n");
4000 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
4002 const char *gl_extensions = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_EXTENSIONS);
4004 if (!gl_extensions)
4006 ERR("Received a NULL GL_EXTENSIONS.\n");
4007 return FALSE;
4009 parse_extension_string(gl_info, gl_extensions, gl_extension_map, ARRAY_SIZE(gl_extension_map));
4011 else
4013 enumerate_gl_extensions(gl_info, gl_extension_map, ARRAY_SIZE(gl_extension_map));
4016 hdc = wglGetCurrentDC();
4017 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
4018 if (GL_EXTCALL(wglGetExtensionsStringARB))
4019 WGL_Extensions = (const char *)GL_EXTCALL(wglGetExtensionsStringARB(hdc));
4020 if (!WGL_Extensions)
4021 WARN("WGL extensions not supported.\n");
4022 else
4023 parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map, ARRAY_SIZE(wgl_extension_map));
4025 for (i = 0; i < ARRAY_SIZE(core_extensions); ++i)
4027 if (!gl_info->supported[core_extensions[i].extension]
4028 && gl_version >= core_extensions[i].min_gl_version)
4030 for (j = 0; j < ARRAY_SIZE(gl_extension_map); ++j)
4031 if (gl_extension_map[j].extension == core_extensions[i].extension)
4032 break;
4034 if (j < ARRAY_SIZE(gl_extension_map))
4036 TRACE("GL CORE: %s support.\n", gl_extension_map[j].extension_string);
4037 gl_info->supported[core_extensions[i].extension] = TRUE;
4039 else
4041 FIXME("GL extension %u not in the GL extensions map.\n", core_extensions[i].extension);
4046 if (gl_info->supported[EXT_BLEND_MINMAX] || gl_info->supported[EXT_BLEND_SUBTRACT])
4047 gl_info->supported[WINED3D_GL_BLEND_EQUATION] = TRUE;
4049 if (gl_version >= MAKEDWORD_VERSION(2, 0))
4050 gl_info->supported[WINED3D_GL_VERSION_2_0] = TRUE;
4051 if (gl_version >= MAKEDWORD_VERSION(3, 2))
4052 gl_info->supported[WINED3D_GL_VERSION_3_2] = TRUE;
4054 /* All the points are actually point sprites in core contexts, the APIs from
4055 * ARB_point_sprite are not supported anymore. */
4056 if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
4057 gl_info->supported[ARB_POINT_SPRITE] = FALSE;
4059 if (gl_info->supported[APPLE_FENCE])
4061 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
4062 * The apple extension interacts with some other apple exts. Disable the NV
4063 * extension if the apple one is support to prevent confusion in other parts
4064 * of the code. */
4065 gl_info->supported[NV_FENCE] = FALSE;
4067 if (gl_info->supported[APPLE_FLOAT_PIXELS])
4069 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
4071 * The enums are the same:
4072 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881a
4073 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881b
4074 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
4075 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
4076 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140b
4078 if (!gl_info->supported[ARB_TEXTURE_FLOAT])
4080 TRACE(" IMPLIED: GL_ARB_texture_float support (by GL_APPLE_float_pixels).\n");
4081 gl_info->supported[ARB_TEXTURE_FLOAT] = TRUE;
4083 if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
4085 TRACE(" IMPLIED: GL_ARB_half_float_pixel support (by GL_APPLE_float_pixels).\n");
4086 gl_info->supported[ARB_HALF_FLOAT_PIXEL] = TRUE;
4089 if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
4091 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
4092 * functionality. Prefer the ARB extension */
4093 gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] = FALSE;
4095 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
4097 TRACE(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
4098 gl_info->supported[NV_TEXGEN_REFLECTION] = TRUE;
4100 if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
4102 TRACE(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
4103 gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE;
4105 if (!gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC] && gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC])
4107 TRACE(" IMPLIED: EXT_texture_compression_rgtc support (by ARB_texture_compression_rgtc).\n");
4108 gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC] = TRUE;
4110 if (!gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] && gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
4112 TRACE(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
4113 gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] = TRUE;
4115 if (gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] && !gl_info->supported[ARB_TEXTURE_RG])
4117 TRACE("ARB_texture_rg not supported, disabling ARB_texture_compression_rgtc.\n");
4118 gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] = FALSE;
4120 if (gl_info->supported[NV_TEXTURE_SHADER2])
4122 if (gl_info->supported[NV_REGISTER_COMBINERS])
4124 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
4125 * are supported. The nv extensions provide the same functionality as the
4126 * ATI one, and a bit more(signed pixelformats). */
4127 gl_info->supported[ATI_FRAGMENT_SHADER] = FALSE;
4130 if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
4132 /* If we have full NP2 texture support, disable
4133 * GL_ARB_texture_rectangle because we will never use it.
4134 * This saves a few redundant glDisable calls. */
4135 gl_info->supported[ARB_TEXTURE_RECTANGLE] = FALSE;
4137 if (gl_info->supported[ATI_FRAGMENT_SHADER])
4139 /* Disable NV_register_combiners and fragment shader if this is supported.
4140 * generally the NV extensions are preferred over the ATI ones, and this
4141 * extension is disabled if register_combiners and texture_shader2 are both
4142 * supported. So we reach this place only if we have incomplete NV dxlevel 8
4143 * fragment processing support. */
4144 gl_info->supported[NV_REGISTER_COMBINERS] = FALSE;
4145 gl_info->supported[NV_REGISTER_COMBINERS2] = FALSE;
4146 gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
4147 gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
4149 if (gl_info->supported[NV_HALF_FLOAT])
4151 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
4152 gl_info->supported[ARB_HALF_FLOAT_VERTEX] = TRUE;
4154 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB] && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
4156 /* Current wined3d sRGB infrastructure requires EXT_texture_sRGB_decode
4157 * for GL_ARB_framebuffer_sRGB support (without EXT_texture_sRGB_decode
4158 * we never render to sRGB surfaces). */
4159 TRACE("EXT_texture_sRGB_decode is not supported, disabling ARB_framebuffer_sRGB.\n");
4160 gl_info->supported[ARB_FRAMEBUFFER_SRGB] = FALSE;
4162 if (gl_info->supported[ARB_OCCLUSION_QUERY])
4164 GLint counter_bits;
4166 GL_EXTCALL(glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, &counter_bits));
4167 TRACE("Occlusion query counter has %d bits.\n", counter_bits);
4168 if (!counter_bits)
4169 gl_info->supported[ARB_OCCLUSION_QUERY] = FALSE;
4171 if (gl_info->supported[ARB_TIMER_QUERY])
4173 GLint counter_bits;
4175 GL_EXTCALL(glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, &counter_bits));
4176 TRACE("Timestamp query counter has %d bits.\n", counter_bits);
4177 if (!counter_bits)
4178 gl_info->supported[ARB_TIMER_QUERY] = FALSE;
4180 if (gl_version >= MAKEDWORD_VERSION(3, 0))
4182 GLint counter_bits;
4184 gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY] = TRUE;
4186 GL_EXTCALL(glGetQueryiv(GL_PRIMITIVES_GENERATED, GL_QUERY_COUNTER_BITS, &counter_bits));
4187 TRACE("Primitives query counter has %d bits.\n", counter_bits);
4188 if (!counter_bits)
4189 gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY] = FALSE;
4191 GL_EXTCALL(glGetQueryiv(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, GL_QUERY_COUNTER_BITS, &counter_bits));
4192 TRACE("Transform feedback primitives query counter has %d bits.\n", counter_bits);
4193 if (!counter_bits)
4194 gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY] = FALSE;
4196 if (gl_info->supported[ARB_VIEWPORT_ARRAY])
4198 GLint subpixel_bits;
4200 gl_info->gl_ops.gl.p_glGetIntegerv(GL_VIEWPORT_SUBPIXEL_BITS, &subpixel_bits);
4201 TRACE("Viewport supports %d subpixel bits.\n", subpixel_bits);
4202 if (subpixel_bits < 8 && gl_info->supported[ARB_CLIP_CONTROL])
4204 TRACE("Disabling ARB_clip_control because viewport subpixel bits < 8.\n");
4205 gl_info->supported[ARB_CLIP_CONTROL] = FALSE;
4208 if (gl_info->supported[ARB_CLIP_CONTROL] && !gl_info->supported[ARB_VIEWPORT_ARRAY])
4210 /* When using ARB_clip_control we need the float viewport parameters
4211 * introduced by ARB_viewport_array to take care of the shifted pixel
4212 * coordinates. */
4213 TRACE("Disabling ARB_clip_control because ARB_viewport_array is not supported.\n");
4214 gl_info->supported[ARB_CLIP_CONTROL] = FALSE;
4216 if (gl_info->supported[ARB_STENCIL_TEXTURING] && !gl_info->supported[ARB_TEXTURE_SWIZZLE])
4218 /* The stencil value needs to be placed in the green channel. */
4219 TRACE("Disabling ARB_stencil_texturing because ARB_texture_swizzle is not supported.\n");
4220 gl_info->supported[ARB_STENCIL_TEXTURING] = FALSE;
4222 if (!gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] && gl_info->supported[EXT_TEXTURE_MIRROR_CLAMP])
4224 TRACE(" IMPLIED: ATI_texture_mirror_once support (by EXT_texture_mirror_clamp).\n");
4225 gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] = TRUE;
4227 if (!gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] && gl_info->supported[ATI_TEXTURE_MIRROR_ONCE])
4229 TRACE(" IMPLIED: ARB_texture_mirror_clamp_to_edge support (by ATI_texture_mirror_once).\n");
4230 gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] = TRUE;
4232 if (gl_info->supported[ARB_TEXTURE_STORAGE] && gl_info->supported[APPLE_YCBCR_422])
4234 /* AFAIK APPLE_ycbcr_422 is only available in legacy contexts so we shouldn't ever hit this. */
4235 ERR("Disabling APPLE_ycbcr_422 because of ARB_texture_storage.\n");
4236 gl_info->supported[APPLE_YCBCR_422] = FALSE;
4238 if (gl_info->supported[ARB_DRAW_INDIRECT] && !gl_info->supported[ARB_BASE_INSTANCE])
4240 /* If ARB_base_instance is not supported the baseInstance field
4241 * in indirect draw parameters must be 0 or behavior is undefined.
4243 WARN("Disabling ARB_draw_indirect because ARB_base_instance is not supported.\n");
4244 gl_info->supported[ARB_DRAW_INDIRECT] = FALSE;
4246 if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE] && !wined3d_settings.multisample_textures)
4247 gl_info->supported[ARB_TEXTURE_MULTISAMPLE] = FALSE;
4248 if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE] && !gl_info->supported[ARB_TEXTURE_STORAGE_MULTISAMPLE])
4250 WARN("Disabling ARB_texture_multisample because immutable storage is not supported.\n");
4251 gl_info->supported[ARB_TEXTURE_MULTISAMPLE] = FALSE;
4254 wined3d_adapter_init_limits(gl_info);
4256 if (gl_info->supported[ARB_VERTEX_PROGRAM] && test_arb_vs_offset_limit(gl_info))
4257 gl_info->quirks |= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT;
4259 if (gl_info->supported[ARB_SHADING_LANGUAGE_100])
4261 const char *str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
4262 unsigned int major, minor;
4264 TRACE("GLSL version string: %s.\n", debugstr_a(str));
4266 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
4267 sscanf(str, "%u.%u", &major, &minor);
4268 gl_info->glsl_version = MAKEDWORD_VERSION(major, minor);
4269 if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 30))
4270 gl_info->supported[WINED3D_GLSL_130] = TRUE;
4273 checkGLcall("extension detection");
4275 adapter->shader_backend = select_shader_backend(gl_info);
4276 adapter->vertex_pipe = select_vertex_implementation(gl_info, adapter->shader_backend);
4277 adapter->fragment_pipe = select_fragment_implementation(gl_info, adapter->shader_backend);
4279 adapter->shader_backend->shader_get_caps(gl_info, &shader_caps);
4280 adapter->d3d_info.vs_clipping = shader_caps.wined3d_caps & WINED3D_SHADER_CAP_VS_CLIPPING;
4281 adapter->d3d_info.limits.vs_version = shader_caps.vs_version;
4282 adapter->d3d_info.limits.hs_version = shader_caps.hs_version;
4283 adapter->d3d_info.limits.ds_version = shader_caps.ds_version;
4284 adapter->d3d_info.limits.gs_version = shader_caps.gs_version;
4285 adapter->d3d_info.limits.ps_version = shader_caps.ps_version;
4286 adapter->d3d_info.limits.cs_version = shader_caps.cs_version;
4287 adapter->d3d_info.limits.vs_uniform_count = shader_caps.vs_uniform_count;
4288 adapter->d3d_info.limits.ps_uniform_count = shader_caps.ps_uniform_count;
4289 adapter->d3d_info.limits.varying_count = shader_caps.varying_count;
4290 adapter->d3d_info.shader_double_precision = shader_caps.wined3d_caps & WINED3D_SHADER_CAP_DOUBLE_PRECISION;
4292 adapter->vertex_pipe->vp_get_caps(gl_info, &vertex_caps);
4293 adapter->d3d_info.xyzrhw = vertex_caps.xyzrhw;
4294 adapter->d3d_info.ffp_generic_attributes = vertex_caps.ffp_generic_attributes;
4295 adapter->d3d_info.limits.ffp_vertex_blend_matrices = vertex_caps.max_vertex_blend_matrices;
4296 adapter->d3d_info.limits.active_light_count = vertex_caps.max_active_lights;
4297 adapter->d3d_info.emulated_flatshading = vertex_caps.emulated_flatshading;
4299 adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
4300 adapter->d3d_info.limits.ffp_blend_stages = fragment_caps.MaxTextureBlendStages;
4301 adapter->d3d_info.limits.ffp_textures = fragment_caps.MaxSimultaneousTextures;
4302 adapter->d3d_info.shader_color_key = fragment_caps.wined3d_caps & WINED3D_FRAGMENT_CAP_COLOR_KEY;
4303 adapter->d3d_info.wined3d_creation_flags = wined3d_creation_flags;
4304 TRACE("Max texture stages: %u.\n", adapter->d3d_info.limits.ffp_blend_stages);
4306 adapter->d3d_info.valid_rt_mask = 0;
4307 for (i = 0; i < gl_info->limits.buffers; ++i)
4308 adapter->d3d_info.valid_rt_mask |= (1u << i);
4310 if (!adapter->d3d_info.shader_color_key)
4312 /* We do not want to deal with re-creating immutable texture storage for color keying emulation. */
4313 WARN("Disabling ARB_texture_storage because fragment pipe doesn't support color keying.\n");
4314 gl_info->supported[ARB_TEXTURE_STORAGE] = FALSE;
4317 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
4319 gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbuffer;
4320 gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbuffer;
4321 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffers;
4322 gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffers;
4323 gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorage;
4324 gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisample;
4325 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameteriv;
4326 gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebuffer;
4327 gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebuffer;
4328 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffers;
4329 gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffers;
4330 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatus;
4331 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1D;
4332 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2D;
4333 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3D;
4334 gl_info->fbo_ops.glFramebufferTextureLayer = gl_info->gl_ops.ext.p_glFramebufferTextureLayer;
4335 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbuffer;
4336 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
4337 = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameteriv;
4338 gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebuffer;
4339 gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmap;
4340 gl_info->fbo_ops.glFramebufferTexture = gl_info->gl_ops.ext.p_glFramebufferTexture;
4342 else
4344 if (gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
4346 gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbufferEXT;
4347 gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbufferEXT;
4348 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffersEXT;
4349 gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffersEXT;
4350 gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorageEXT;
4351 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameterivEXT;
4352 gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebufferEXT;
4353 gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebufferEXT;
4354 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffersEXT;
4355 gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffersEXT;
4356 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatusEXT;
4357 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1DEXT;
4358 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2DEXT;
4359 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3DEXT;
4360 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbufferEXT;
4361 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
4362 = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameterivEXT;
4363 gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmapEXT;
4365 else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
4367 WARN_(d3d_perf)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
4368 wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
4371 if (gl_info->supported[ARB_GEOMETRY_SHADER4])
4373 gl_info->fbo_ops.glFramebufferTexture = gl_info->gl_ops.ext.p_glFramebufferTextureARB;
4374 gl_info->fbo_ops.glFramebufferTextureLayer = gl_info->gl_ops.ext.p_glFramebufferTextureLayerARB;
4376 if (gl_info->supported[EXT_FRAMEBUFFER_BLIT])
4378 gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebufferEXT;
4380 if (gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
4382 gl_info->fbo_ops.glRenderbufferStorageMultisample
4383 = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisampleEXT;
4387 gl_info->wrap_lookup[WINED3D_TADDRESS_WRAP - WINED3D_TADDRESS_WRAP] = GL_REPEAT;
4388 gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR - WINED3D_TADDRESS_WRAP] =
4389 gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
4390 gl_info->wrap_lookup[WINED3D_TADDRESS_CLAMP - WINED3D_TADDRESS_WRAP] = GL_CLAMP_TO_EDGE;
4391 gl_info->wrap_lookup[WINED3D_TADDRESS_BORDER - WINED3D_TADDRESS_WRAP] =
4392 gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
4393 gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP] =
4394 gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] ? GL_MIRROR_CLAMP_TO_EDGE : GL_REPEAT;
4396 if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
4398 GLuint vao;
4400 GL_EXTCALL(glGenVertexArrays(1, &vao));
4401 GL_EXTCALL(glBindVertexArray(vao));
4402 checkGLcall("creating VAO");
4405 gl_vendor = wined3d_guess_gl_vendor(gl_info, gl_vendor_str, gl_renderer_str, gl_version_str);
4406 TRACE("Guessed GL vendor %#x.\n", gl_vendor);
4408 if (!(gpu_description = query_gpu_description(gl_info, &vram_bytes)))
4410 enum wined3d_pci_vendor vendor;
4411 enum wined3d_pci_device device;
4413 vendor = wined3d_guess_card_vendor(gl_vendor_str, gl_renderer_str);
4414 TRACE("Guessed vendor PCI ID 0x%04x.\n", vendor);
4416 device = wined3d_guess_card(&shader_caps, &fragment_caps, gl_info->glsl_version,
4417 gl_renderer_str, &gl_vendor, &vendor);
4418 TRACE("Guessed device PCI ID 0x%04x.\n", device);
4420 if (!(gpu_description = get_gpu_description(vendor, device)))
4422 ERR("Card %04x:%04x not found in driver DB.\n", vendor, device);
4423 return FALSE;
4426 fixup_extensions(gl_info, caps_gl_ctx, gl_renderer_str, gl_vendor,
4427 gpu_description->vendor, gpu_description->card);
4428 init_driver_info(driver_info, gpu_description, vram_bytes);
4430 gl_ext_emul_mask = adapter->vertex_pipe->vp_get_emul_mask(gl_info)
4431 | adapter->fragment_pipe->get_emul_mask(gl_info);
4432 if (gl_ext_emul_mask & GL_EXT_EMUL_ARB_MULTITEXTURE)
4433 install_gl_compat_wrapper(gl_info, ARB_MULTITEXTURE);
4434 if (gl_ext_emul_mask & GL_EXT_EMUL_EXT_FOG_COORD)
4435 install_gl_compat_wrapper(gl_info, EXT_FOG_COORD);
4437 return TRUE;
4440 UINT CDECL wined3d_get_adapter_count(const struct wined3d *wined3d)
4442 TRACE("wined3d %p, reporting %u adapters.\n",
4443 wined3d, wined3d->adapter_count);
4445 return wined3d->adapter_count;
4448 HRESULT CDECL wined3d_register_software_device(struct wined3d *wined3d, void *init_function)
4450 FIXME("wined3d %p, init_function %p stub!\n", wined3d, init_function);
4452 return WINED3D_OK;
4455 HRESULT CDECL wined3d_get_output_desc(const struct wined3d *wined3d, unsigned int adapter_idx,
4456 struct wined3d_output_desc *desc)
4458 enum wined3d_display_rotation rotation;
4459 const struct wined3d_adapter *adapter;
4460 struct wined3d_display_mode mode;
4461 HMONITOR monitor;
4462 HRESULT hr;
4464 TRACE("wined3d %p, adapter_idx %u, desc %p.\n", wined3d, adapter_idx, desc);
4466 if (adapter_idx >= wined3d->adapter_count)
4467 return WINED3DERR_INVALIDCALL;
4469 adapter = &wined3d->adapters[adapter_idx];
4470 if (!(monitor = MonitorFromPoint(adapter->monitor_position, MONITOR_DEFAULTTOPRIMARY)))
4471 return WINED3DERR_INVALIDCALL;
4473 if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx, &mode, &rotation)))
4474 return hr;
4476 memcpy(desc->device_name, adapter->DeviceName, sizeof(desc->device_name));
4477 SetRect(&desc->desktop_rect, 0, 0, mode.width, mode.height);
4478 OffsetRect(&desc->desktop_rect, adapter->monitor_position.x, adapter->monitor_position.y);
4479 /* FIXME: We should get this from EnumDisplayDevices() when the adapters
4480 * are created. */
4481 desc->attached_to_desktop = TRUE;
4482 desc->rotation = rotation;
4483 desc->monitor = monitor;
4485 return WINED3D_OK;
4488 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
4489 of the same bpp but different resolutions */
4491 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
4492 UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT adapter_idx,
4493 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering)
4495 const struct wined3d_adapter *adapter;
4496 const struct wined3d_format *format;
4497 unsigned int i = 0;
4498 unsigned int j = 0;
4499 UINT format_bits;
4500 DEVMODEW mode;
4502 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x.\n",
4503 wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering);
4505 if (adapter_idx >= wined3d->adapter_count)
4506 return 0;
4508 adapter = &wined3d->adapters[adapter_idx];
4509 format = wined3d_get_format(&adapter->gl_info, format_id, WINED3DUSAGE_RENDERTARGET);
4510 format_bits = format->byte_count * CHAR_BIT;
4512 memset(&mode, 0, sizeof(mode));
4513 mode.dmSize = sizeof(mode);
4515 while (EnumDisplaySettingsExW(adapter->DeviceName, j++, &mode, 0))
4517 if (mode.dmFields & DM_DISPLAYFLAGS)
4519 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
4520 && (mode.u2.dmDisplayFlags & DM_INTERLACED))
4521 continue;
4523 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
4524 && !(mode.u2.dmDisplayFlags & DM_INTERLACED))
4525 continue;
4528 if (format_id == WINED3DFMT_UNKNOWN)
4530 /* This is for d3d8, do not enumerate P8 here. */
4531 if (mode.dmBitsPerPel == 32 || mode.dmBitsPerPel == 16) ++i;
4533 else if (mode.dmBitsPerPel == format_bits)
4535 ++i;
4539 TRACE("Returning %u matching modes (out of %u total) for adapter %u.\n", i, j, adapter_idx);
4541 return i;
4544 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
4545 HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT adapter_idx,
4546 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering,
4547 UINT mode_idx, struct wined3d_display_mode *mode)
4549 const struct wined3d_adapter *adapter;
4550 const struct wined3d_format *format;
4551 UINT format_bits;
4552 DEVMODEW m;
4553 UINT i = 0;
4554 int j = 0;
4556 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x, mode_idx %u, mode %p.\n",
4557 wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering, mode_idx, mode);
4559 if (!mode || adapter_idx >= wined3d->adapter_count)
4560 return WINED3DERR_INVALIDCALL;
4562 adapter = &wined3d->adapters[adapter_idx];
4563 format = wined3d_get_format(&adapter->gl_info, format_id, WINED3DUSAGE_RENDERTARGET);
4564 format_bits = format->byte_count * CHAR_BIT;
4566 memset(&m, 0, sizeof(m));
4567 m.dmSize = sizeof(m);
4569 while (i <= mode_idx)
4571 if (!EnumDisplaySettingsExW(adapter->DeviceName, j++, &m, 0))
4573 WARN("Invalid mode_idx %u.\n", mode_idx);
4574 return WINED3DERR_INVALIDCALL;
4577 if (m.dmFields & DM_DISPLAYFLAGS)
4579 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
4580 && (m.u2.dmDisplayFlags & DM_INTERLACED))
4581 continue;
4583 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
4584 && !(m.u2.dmDisplayFlags & DM_INTERLACED))
4585 continue;
4588 if (format_id == WINED3DFMT_UNKNOWN)
4590 /* This is for d3d8, do not enumerate P8 here. */
4591 if (m.dmBitsPerPel == 32 || m.dmBitsPerPel == 16) ++i;
4593 else if (m.dmBitsPerPel == format_bits)
4595 ++i;
4599 mode->width = m.dmPelsWidth;
4600 mode->height = m.dmPelsHeight;
4601 mode->refresh_rate = DEFAULT_REFRESH_RATE;
4602 if (m.dmFields & DM_DISPLAYFREQUENCY)
4603 mode->refresh_rate = m.dmDisplayFrequency;
4605 if (format_id == WINED3DFMT_UNKNOWN)
4606 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
4607 else
4608 mode->format_id = format_id;
4610 if (!(m.dmFields & DM_DISPLAYFLAGS))
4611 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
4612 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
4613 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
4614 else
4615 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
4617 TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
4618 m.dmBitsPerPel, debug_d3dformat(mode->format_id), mode->scanline_ordering);
4620 return WINED3D_OK;
4623 HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *wined3d,
4624 unsigned int adapter_idx, struct wined3d_display_mode *mode)
4626 unsigned int i, j, mode_count, matching_mode_count, closest;
4627 struct wined3d_display_mode **matching_modes;
4628 struct wined3d_display_mode *modes;
4629 HRESULT hr;
4631 TRACE("wined3d %p, adapter_idx %u, mode %p.\n", wined3d, adapter_idx, mode);
4633 if (!(mode_count = wined3d_get_adapter_mode_count(wined3d, adapter_idx,
4634 mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN)))
4636 WARN("Adapter has 0 matching modes.\n");
4637 return E_FAIL;
4640 if (!(modes = heap_calloc(mode_count, sizeof(*modes))))
4641 return E_OUTOFMEMORY;
4642 if (!(matching_modes = heap_calloc(mode_count, sizeof(*matching_modes))))
4644 heap_free(modes);
4645 return E_OUTOFMEMORY;
4648 for (i = 0; i < mode_count; ++i)
4650 if (FAILED(hr = wined3d_enum_adapter_modes(wined3d, adapter_idx,
4651 mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN, i, &modes[i])))
4653 heap_free(matching_modes);
4654 heap_free(modes);
4655 return hr;
4657 matching_modes[i] = &modes[i];
4660 matching_mode_count = mode_count;
4662 if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
4664 for (i = 0, j = 0; i < matching_mode_count; ++i)
4666 if (matching_modes[i]->scanline_ordering == mode->scanline_ordering)
4667 matching_modes[j++] = matching_modes[i];
4669 if (j > 0)
4670 matching_mode_count = j;
4673 if (mode->refresh_rate)
4675 for (i = 0, j = 0; i < matching_mode_count; ++i)
4677 if (matching_modes[i]->refresh_rate == mode->refresh_rate)
4678 matching_modes[j++] = matching_modes[i];
4680 if (j > 0)
4681 matching_mode_count = j;
4684 if (!mode->width || !mode->height)
4686 struct wined3d_display_mode current_mode;
4687 if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx,
4688 &current_mode, NULL)))
4690 heap_free(matching_modes);
4691 heap_free(modes);
4692 return hr;
4694 mode->width = current_mode.width;
4695 mode->height = current_mode.height;
4698 closest = ~0u;
4699 for (i = 0, j = 0; i < matching_mode_count; ++i)
4701 unsigned int d = abs(mode->width - matching_modes[i]->width)
4702 + abs(mode->height - matching_modes[i]->height);
4704 if (closest > d)
4706 closest = d;
4707 j = i;
4711 *mode = *matching_modes[j];
4713 heap_free(matching_modes);
4714 heap_free(modes);
4716 TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
4717 mode->refresh_rate, debug_d3dformat(mode->format_id),
4718 mode->scanline_ordering);
4720 return WINED3D_OK;
4723 HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx,
4724 struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
4726 const struct wined3d_adapter *adapter;
4727 DEVMODEW m;
4729 TRACE("wined3d %p, adapter_idx %u, display_mode %p, rotation %p.\n",
4730 wined3d, adapter_idx, mode, rotation);
4732 if (!mode || adapter_idx >= wined3d->adapter_count)
4733 return WINED3DERR_INVALIDCALL;
4735 adapter = &wined3d->adapters[adapter_idx];
4737 memset(&m, 0, sizeof(m));
4738 m.dmSize = sizeof(m);
4740 EnumDisplaySettingsExW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &m, 0);
4741 mode->width = m.dmPelsWidth;
4742 mode->height = m.dmPelsHeight;
4743 mode->refresh_rate = DEFAULT_REFRESH_RATE;
4744 if (m.dmFields & DM_DISPLAYFREQUENCY)
4745 mode->refresh_rate = m.dmDisplayFrequency;
4746 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
4748 /* Lie about the format. X11 can't change the color depth, and some apps
4749 * are pretty angry if they SetDisplayMode from 24 to 16 bpp and find out
4750 * that GetDisplayMode still returns 24 bpp. This should probably be
4751 * handled in winex11 instead. */
4752 if (adapter->screen_format && adapter->screen_format != mode->format_id)
4754 WARN("Overriding format %s with stored format %s.\n",
4755 debug_d3dformat(mode->format_id),
4756 debug_d3dformat(adapter->screen_format));
4757 mode->format_id = adapter->screen_format;
4760 if (!(m.dmFields & DM_DISPLAYFLAGS))
4761 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
4762 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
4763 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
4764 else
4765 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
4767 if (rotation)
4769 switch (m.u1.s2.dmDisplayOrientation)
4771 case DMDO_DEFAULT:
4772 *rotation = WINED3D_DISPLAY_ROTATION_0;
4773 break;
4774 case DMDO_90:
4775 *rotation = WINED3D_DISPLAY_ROTATION_90;
4776 break;
4777 case DMDO_180:
4778 *rotation = WINED3D_DISPLAY_ROTATION_180;
4779 break;
4780 case DMDO_270:
4781 *rotation = WINED3D_DISPLAY_ROTATION_270;
4782 break;
4783 default:
4784 FIXME("Unhandled display rotation %#x.\n", m.u1.s2.dmDisplayOrientation);
4785 *rotation = WINED3D_DISPLAY_ROTATION_UNSPECIFIED;
4786 break;
4790 TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
4791 mode->refresh_rate, debug_d3dformat(mode->format_id),
4792 mode->scanline_ordering);
4793 return WINED3D_OK;
4796 HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d,
4797 UINT adapter_idx, const struct wined3d_display_mode *mode)
4799 struct wined3d_adapter *adapter;
4800 DEVMODEW new_mode, current_mode;
4801 RECT clip_rc;
4802 LONG ret;
4803 enum wined3d_format_id new_format_id;
4805 TRACE("wined3d %p, adapter_idx %u, mode %p.\n", wined3d, adapter_idx, mode);
4807 if (adapter_idx >= wined3d->adapter_count)
4808 return WINED3DERR_INVALIDCALL;
4809 adapter = &wined3d->adapters[adapter_idx];
4811 memset(&new_mode, 0, sizeof(new_mode));
4812 new_mode.dmSize = sizeof(new_mode);
4813 memset(&current_mode, 0, sizeof(current_mode));
4814 current_mode.dmSize = sizeof(current_mode);
4815 if (mode)
4817 const struct wined3d_format *format;
4819 TRACE("mode %ux%u@%u %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
4820 debug_d3dformat(mode->format_id), mode->scanline_ordering);
4822 format = wined3d_get_format(&adapter->gl_info, mode->format_id, WINED3DUSAGE_RENDERTARGET);
4824 new_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
4825 new_mode.dmBitsPerPel = format->byte_count * CHAR_BIT;
4826 new_mode.dmPelsWidth = mode->width;
4827 new_mode.dmPelsHeight = mode->height;
4829 new_mode.dmDisplayFrequency = mode->refresh_rate;
4830 if (mode->refresh_rate)
4831 new_mode.dmFields |= DM_DISPLAYFREQUENCY;
4833 if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
4835 new_mode.dmFields |= DM_DISPLAYFLAGS;
4836 if (mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED)
4837 new_mode.u2.dmDisplayFlags |= DM_INTERLACED;
4839 new_format_id = mode->format_id;
4841 else
4843 if (!EnumDisplaySettingsW(adapter->DeviceName, ENUM_REGISTRY_SETTINGS, &new_mode))
4845 ERR("Failed to read mode from registry.\n");
4846 return WINED3DERR_NOTAVAILABLE;
4848 new_format_id = pixelformat_for_depth(new_mode.dmBitsPerPel);
4851 /* Only change the mode if necessary. */
4852 if (!EnumDisplaySettingsW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &current_mode))
4854 ERR("Failed to get current display mode.\n");
4856 else if (current_mode.dmPelsWidth == new_mode.dmPelsWidth
4857 && current_mode.dmPelsHeight == new_mode.dmPelsHeight
4858 && current_mode.dmBitsPerPel == new_mode.dmBitsPerPel
4859 && (current_mode.dmDisplayFrequency == new_mode.dmDisplayFrequency
4860 || !(new_mode.dmFields & DM_DISPLAYFREQUENCY))
4861 && (current_mode.u2.dmDisplayFlags == new_mode.u2.dmDisplayFlags
4862 || !(new_mode.dmFields & DM_DISPLAYFLAGS)))
4864 TRACE("Skipping redundant mode setting call.\n");
4865 adapter->screen_format = new_format_id;
4866 return WINED3D_OK;
4869 ret = ChangeDisplaySettingsExW(adapter->DeviceName, &new_mode, NULL, CDS_FULLSCREEN, NULL);
4870 if (ret != DISP_CHANGE_SUCCESSFUL)
4872 if (new_mode.dmFields & DM_DISPLAYFREQUENCY)
4874 WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate.\n");
4875 new_mode.dmFields &= ~DM_DISPLAYFREQUENCY;
4876 new_mode.dmDisplayFrequency = 0;
4877 ret = ChangeDisplaySettingsExW(adapter->DeviceName, &new_mode, NULL, CDS_FULLSCREEN, NULL);
4879 if (ret != DISP_CHANGE_SUCCESSFUL)
4880 return WINED3DERR_NOTAVAILABLE;
4883 /* Store the new values. */
4884 adapter->screen_format = new_format_id;
4886 /* And finally clip mouse to our screen. */
4887 SetRect(&clip_rc, 0, 0, new_mode.dmPelsWidth, new_mode.dmPelsHeight);
4888 ClipCursor(&clip_rc);
4890 return WINED3D_OK;
4893 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
4894 and fields being inserted in the middle, a new structure is used in place */
4895 HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d,
4896 UINT adapter_idx, DWORD flags, struct wined3d_adapter_identifier *identifier)
4898 const struct wined3d_adapter *adapter;
4899 size_t len;
4901 TRACE("wined3d %p, adapter_idx %u, flags %#x, identifier %p.\n",
4902 wined3d, adapter_idx, flags, identifier);
4904 if (adapter_idx >= wined3d->adapter_count)
4905 return WINED3DERR_INVALIDCALL;
4907 adapter = &wined3d->adapters[adapter_idx];
4909 if (identifier->driver_size)
4911 const char *name = adapter->driver_info.name;
4912 len = min(strlen(name), identifier->driver_size - 1);
4913 memcpy(identifier->driver, name, len);
4914 memset(&identifier->driver[len], 0, identifier->driver_size - len);
4917 if (identifier->description_size)
4919 const char *description = adapter->driver_info.description;
4920 len = min(strlen(description), identifier->description_size - 1);
4921 memcpy(identifier->description, description, len);
4922 memset(&identifier->description[len], 0, identifier->description_size - len);
4925 /* Note that d3d8 doesn't supply a device name. */
4926 if (identifier->device_name_size)
4928 if (!WideCharToMultiByte(CP_ACP, 0, adapter->DeviceName, -1, identifier->device_name,
4929 identifier->device_name_size, NULL, NULL))
4931 ERR("Failed to convert device name, last error %#x.\n", GetLastError());
4932 return WINED3DERR_INVALIDCALL;
4936 identifier->driver_version.u.HighPart = adapter->driver_info.version_high;
4937 identifier->driver_version.u.LowPart = adapter->driver_info.version_low;
4938 identifier->vendor_id = adapter->driver_info.vendor;
4939 identifier->device_id = adapter->driver_info.device;
4940 identifier->subsystem_id = 0;
4941 identifier->revision = 0;
4942 memcpy(&identifier->device_identifier, &IID_D3DDEVICE_D3DUID, sizeof(identifier->device_identifier));
4943 identifier->whql_level = (flags & WINED3DENUM_NO_WHQL_LEVEL) ? 0 : 1;
4944 memcpy(&identifier->adapter_luid, &adapter->luid, sizeof(identifier->adapter_luid));
4945 identifier->video_memory = min(~(SIZE_T)0, adapter->vram_bytes);
4947 return WINED3D_OK;
4950 HRESULT CDECL wined3d_get_adapter_raster_status(const struct wined3d *wined3d, UINT adapter_idx,
4951 struct wined3d_raster_status *raster_status)
4953 LONGLONG freq_per_frame, freq_per_line;
4954 LARGE_INTEGER counter, freq_per_sec;
4955 struct wined3d_display_mode mode;
4956 static UINT once;
4958 if (!once++)
4959 FIXME("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
4960 wined3d, adapter_idx, raster_status);
4961 else
4962 WARN("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
4963 wined3d, adapter_idx, raster_status);
4965 /* Obtaining the raster status is a widely implemented but optional
4966 * feature. When this method returns OK StarCraft 2 expects the
4967 * raster_status->InVBlank value to actually change over time.
4968 * And Endless Alice Crysis doesn't care even if this method fails.
4969 * Thus this method returns OK and fakes raster_status by
4970 * QueryPerformanceCounter. */
4972 if (!QueryPerformanceCounter(&counter) || !QueryPerformanceFrequency(&freq_per_sec))
4973 return WINED3DERR_INVALIDCALL;
4974 if (FAILED(wined3d_get_adapter_display_mode(wined3d, adapter_idx, &mode, NULL)))
4975 return WINED3DERR_INVALIDCALL;
4976 if (mode.refresh_rate == DEFAULT_REFRESH_RATE)
4977 mode.refresh_rate = 60;
4979 freq_per_frame = freq_per_sec.QuadPart / mode.refresh_rate;
4980 /* Assume 20 scan lines in the vertical blank. */
4981 freq_per_line = freq_per_frame / (mode.height + 20);
4982 raster_status->scan_line = (counter.QuadPart % freq_per_frame) / freq_per_line;
4983 if (raster_status->scan_line < mode.height)
4984 raster_status->in_vblank = FALSE;
4985 else
4987 raster_status->scan_line = 0;
4988 raster_status->in_vblank = TRUE;
4991 TRACE("Returning fake value, in_vblank %u, scan_line %u.\n",
4992 raster_status->in_vblank, raster_status->scan_line);
4994 return WINED3D_OK;
4997 static BOOL wined3d_check_pixel_format_color(const struct wined3d_gl_info *gl_info,
4998 const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
5000 /* Float formats need FBOs. If FBOs are used this function isn't called */
5001 if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
5002 return FALSE;
5004 /* Probably a RGBA_float or color index mode. */
5005 if (cfg->iPixelType != WGL_TYPE_RGBA_ARB)
5006 return FALSE;
5008 if (cfg->redSize < format->red_size
5009 || cfg->greenSize < format->green_size
5010 || cfg->blueSize < format->blue_size
5011 || cfg->alphaSize < format->alpha_size)
5012 return FALSE;
5014 return TRUE;
5017 static BOOL wined3d_check_pixel_format_depth(const struct wined3d_gl_info *gl_info,
5018 const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
5020 BOOL lockable = FALSE;
5022 /* Float formats need FBOs. If FBOs are used this function isn't called */
5023 if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
5024 return FALSE;
5026 if ((format->id == WINED3DFMT_D16_LOCKABLE) || (format->id == WINED3DFMT_D32_FLOAT))
5027 lockable = TRUE;
5029 /* On some modern cards like the Geforce8/9, GLX doesn't offer some
5030 * depth/stencil formats which D3D9 reports. We can safely report
5031 * "compatible" formats (e.g. D24 can be used for D16) as long as we
5032 * aren't dealing with a lockable format. This also helps D3D <= 7 as they
5033 * expect D16 which isn't offered without this on Geforce8 cards. */
5034 if (!(cfg->depthSize == format->depth_size || (!lockable && cfg->depthSize > format->depth_size)))
5035 return FALSE;
5037 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also
5038 * need a format without stencil. We can allow a mismatch if the format
5039 * doesn't have any stencil bits. If it does have stencil bits the size
5040 * must match, or stencil wrapping would break. */
5041 if (format->stencil_size && cfg->stencilSize != format->stencil_size)
5042 return FALSE;
5044 return TRUE;
5047 HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d *wined3d,
5048 UINT adapter_idx, enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id,
5049 enum wined3d_format_id render_target_format_id, enum wined3d_format_id depth_stencil_format_id)
5051 const struct wined3d_format *rt_format;
5052 const struct wined3d_format *ds_format;
5053 const struct wined3d_adapter *adapter;
5055 TRACE("wined3d %p, adapter_idx %u, device_type %s,\n"
5056 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
5057 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
5058 debug_d3dformat(render_target_format_id), debug_d3dformat(depth_stencil_format_id));
5060 if (adapter_idx >= wined3d->adapter_count)
5061 return WINED3DERR_INVALIDCALL;
5063 adapter = &wined3d->adapters[adapter_idx];
5064 rt_format = wined3d_get_format(&adapter->gl_info, render_target_format_id, WINED3DUSAGE_RENDERTARGET);
5065 ds_format = wined3d_get_format(&adapter->gl_info, depth_stencil_format_id, WINED3DUSAGE_DEPTHSTENCIL);
5066 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
5068 if ((rt_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_RENDERTARGET)
5069 && (ds_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
5071 TRACE("Formats match.\n");
5072 return WINED3D_OK;
5075 else
5077 const struct wined3d_pixel_format *cfgs;
5078 unsigned int cfg_count;
5079 unsigned int i;
5081 cfgs = adapter->cfgs;
5082 cfg_count = adapter->cfg_count;
5083 for (i = 0; i < cfg_count; ++i)
5085 if (wined3d_check_pixel_format_color(&adapter->gl_info, &cfgs[i], rt_format)
5086 && wined3d_check_pixel_format_depth(&adapter->gl_info, &cfgs[i], ds_format))
5088 TRACE("Formats match.\n");
5089 return WINED3D_OK;
5094 TRACE("Unsupported format pair: %s and %s.\n",
5095 debug_d3dformat(render_target_format_id),
5096 debug_d3dformat(depth_stencil_format_id));
5098 return WINED3DERR_NOTAVAILABLE;
5101 HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3d, UINT adapter_idx,
5102 enum wined3d_device_type device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
5103 enum wined3d_multisample_type multisample_type, DWORD *quality_levels)
5105 const struct wined3d_gl_info *gl_info = &wined3d->adapters[adapter_idx].gl_info;
5106 const struct wined3d_format *format = wined3d_get_format(gl_info, surface_format_id, 0);
5107 HRESULT hr = WINED3D_OK;
5109 TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s, "
5110 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
5111 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(surface_format_id),
5112 windowed, multisample_type, quality_levels);
5114 if (adapter_idx >= wined3d->adapter_count)
5115 return WINED3DERR_INVALIDCALL;
5116 if (surface_format_id == WINED3DFMT_UNKNOWN)
5117 return WINED3DERR_INVALIDCALL;
5118 if (multisample_type < WINED3D_MULTISAMPLE_NONE)
5119 return WINED3DERR_INVALIDCALL;
5120 if (multisample_type > WINED3D_MULTISAMPLE_16_SAMPLES)
5122 FIXME("multisample_type %u not handled yet.\n", multisample_type);
5123 return WINED3DERR_NOTAVAILABLE;
5126 if (multisample_type && !(format->multisample_types & 1u << (multisample_type - 1)))
5127 hr = WINED3DERR_NOTAVAILABLE;
5129 if (SUCCEEDED(hr) || (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE && format->multisample_types))
5131 if (quality_levels)
5133 if (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE)
5134 *quality_levels = wined3d_popcount(format->multisample_types);
5135 else
5136 *quality_levels = 1;
5138 return WINED3D_OK;
5141 TRACE("Returning not supported.\n");
5142 return hr;
5145 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
5146 static BOOL CheckDepthStencilCapability(const struct wined3d_adapter *adapter,
5147 const struct wined3d_format *display_format, const struct wined3d_format *ds_format,
5148 enum wined3d_gl_resource_type gl_type)
5150 /* Only allow depth/stencil formats */
5151 if (!(ds_format->depth_size || ds_format->stencil_size)) return FALSE;
5153 /* Blacklist formats not supported on Windows */
5154 switch (ds_format->id)
5156 case WINED3DFMT_S1_UINT_D15_UNORM: /* Breaks the shadowvol2 dx7 sdk sample */
5157 case WINED3DFMT_S4X4_UINT_D24_UNORM:
5158 TRACE("[FAILED] - not supported on windows.\n");
5159 return FALSE;
5161 default:
5162 break;
5165 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
5167 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
5168 if (ds_format->flags[gl_type] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
5169 return TRUE;
5171 else
5173 unsigned int i;
5175 /* Walk through all WGL pixel formats to find a match */
5176 for (i = 0; i < adapter->cfg_count; ++i)
5178 const struct wined3d_pixel_format *cfg = &adapter->cfgs[i];
5179 if (wined3d_check_pixel_format_color(&adapter->gl_info, cfg, display_format)
5180 && wined3d_check_pixel_format_depth(&adapter->gl_info, cfg, ds_format))
5181 return TRUE;
5185 return FALSE;
5188 /* Check the render target capabilities of a format */
5189 static BOOL CheckRenderTargetCapability(const struct wined3d_adapter *adapter,
5190 const struct wined3d_format *adapter_format, const struct wined3d_format *check_format,
5191 enum wined3d_gl_resource_type gl_type)
5193 /* Filter out non-RT formats */
5194 if (!(check_format->flags[gl_type] & WINED3DFMT_FLAG_RENDERTARGET))
5195 return FALSE;
5196 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
5197 return TRUE;
5198 if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
5200 const struct wined3d_pixel_format *cfgs = adapter->cfgs;
5201 unsigned int i;
5203 /* In backbuffer mode the front and backbuffer share the same WGL
5204 * pixelformat. The format must match in RGB, alpha is allowed to be
5205 * different. (Only the backbuffer can have alpha.) */
5206 if (adapter_format->red_size != check_format->red_size
5207 || adapter_format->green_size != check_format->green_size
5208 || adapter_format->blue_size != check_format->blue_size)
5210 TRACE("[FAILED]\n");
5211 return FALSE;
5214 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
5215 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
5216 for (i = 0; i < adapter->cfg_count; ++i)
5218 if (cfgs[i].windowDrawable
5219 && wined3d_check_pixel_format_color(&adapter->gl_info, &cfgs[i], check_format))
5221 TRACE("Pixel format %d is compatible with format %s.\n",
5222 cfgs[i].iPixelFormat, debug_d3dformat(check_format->id));
5223 return TRUE;
5227 return FALSE;
5230 static BOOL wined3d_check_surface_capability(const struct wined3d_format *format, BOOL no3d)
5232 if (no3d)
5234 switch (format->id)
5236 case WINED3DFMT_B8G8R8_UNORM:
5237 TRACE("[FAILED] - Not enumerated on Windows.\n");
5238 return FALSE;
5239 case WINED3DFMT_B8G8R8A8_UNORM:
5240 case WINED3DFMT_B8G8R8X8_UNORM:
5241 case WINED3DFMT_B5G6R5_UNORM:
5242 case WINED3DFMT_B5G5R5X1_UNORM:
5243 case WINED3DFMT_B5G5R5A1_UNORM:
5244 case WINED3DFMT_B4G4R4A4_UNORM:
5245 case WINED3DFMT_B2G3R3_UNORM:
5246 case WINED3DFMT_A8_UNORM:
5247 case WINED3DFMT_B2G3R3A8_UNORM:
5248 case WINED3DFMT_B4G4R4X4_UNORM:
5249 case WINED3DFMT_R10G10B10A2_UNORM:
5250 case WINED3DFMT_R8G8B8A8_UNORM:
5251 case WINED3DFMT_R8G8B8X8_UNORM:
5252 case WINED3DFMT_R16G16_UNORM:
5253 case WINED3DFMT_B10G10R10A2_UNORM:
5254 case WINED3DFMT_R16G16B16A16_UNORM:
5255 case WINED3DFMT_P8_UINT:
5256 TRACE("[OK]\n");
5257 return TRUE;
5258 default:
5259 TRACE("[FAILED] - Not available on GDI surfaces.\n");
5260 return FALSE;
5264 if (format->glInternal)
5266 TRACE("[OK]\n");
5267 return TRUE;
5270 if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_EXTENSION | WINED3DFMT_FLAG_TEXTURE))
5271 == (WINED3DFMT_FLAG_EXTENSION | WINED3DFMT_FLAG_TEXTURE))
5273 TRACE("[OK]\n");
5274 return TRUE;
5277 /* Reject other formats */
5278 TRACE("[FAILED]\n");
5279 return FALSE;
5282 /* OpenGL supports mipmapping on all formats. Wrapping is unsupported, but we
5283 * have to report mipmapping so we cannot reject WRAPANDMIP. Tests show that
5284 * Windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to
5285 * show that wrapping is supported. The lack of filtering will sort out the
5286 * mipmapping capability anyway.
5288 * For now lets report this on all formats, but in the future we may want to
5289 * restrict it to some should applications need that. */
5290 HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT adapter_idx,
5291 enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
5292 enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id)
5294 const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
5295 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
5296 const struct wined3d_format *adapter_format, *format;
5297 enum wined3d_gl_resource_type gl_type, gl_type_end;
5298 BOOL mipmap_gen_supported = TRUE;
5299 DWORD format_flags = 0;
5300 DWORD allowed_usage;
5302 TRACE("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s, "
5303 "resource_type %s, check_format %s.\n",
5304 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
5305 debug_d3dusage(usage), debug_d3dusagequery(usage), debug_d3dresourcetype(resource_type),
5306 debug_d3dformat(check_format_id));
5308 if (adapter_idx >= wined3d->adapter_count)
5309 return WINED3DERR_INVALIDCALL;
5311 adapter_format = wined3d_get_format(gl_info, adapter_format_id, WINED3DUSAGE_RENDERTARGET);
5312 format = wined3d_get_format(gl_info, check_format_id, usage);
5314 switch (resource_type)
5316 case WINED3D_RTYPE_NONE:
5317 allowed_usage = WINED3DUSAGE_DEPTHSTENCIL
5318 | WINED3DUSAGE_RENDERTARGET;
5319 gl_type = WINED3D_GL_RES_TYPE_TEX_2D;
5320 gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D;
5321 break;
5323 case WINED3D_RTYPE_TEXTURE_1D:
5324 allowed_usage = WINED3DUSAGE_DYNAMIC
5325 | WINED3DUSAGE_SOFTWAREPROCESSING
5326 | WINED3DUSAGE_TEXTURE
5327 | WINED3DUSAGE_QUERY_FILTER
5328 | WINED3DUSAGE_QUERY_GENMIPMAP
5329 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
5330 | WINED3DUSAGE_QUERY_SRGBREAD
5331 | WINED3DUSAGE_QUERY_SRGBWRITE
5332 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
5333 | WINED3DUSAGE_QUERY_WRAPANDMIP;
5334 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_1D;
5335 break;
5337 case WINED3D_RTYPE_TEXTURE_2D:
5338 allowed_usage = WINED3DUSAGE_DEPTHSTENCIL
5339 | WINED3DUSAGE_RENDERTARGET
5340 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
5341 if (usage & WINED3DUSAGE_RENDERTARGET)
5342 allowed_usage |= WINED3DUSAGE_QUERY_SRGBWRITE;
5343 if (!(usage & WINED3DUSAGE_TEXTURE))
5345 if (!wined3d_check_surface_capability(format, wined3d->flags & WINED3D_NO3D))
5347 TRACE("[FAILED] - Not supported for plain surfaces.\n");
5348 return WINED3DERR_NOTAVAILABLE;
5351 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_RB;
5352 break;
5354 allowed_usage |= WINED3DUSAGE_DYNAMIC
5355 | WINED3DUSAGE_LEGACY_CUBEMAP
5356 | WINED3DUSAGE_SOFTWAREPROCESSING
5357 | WINED3DUSAGE_TEXTURE
5358 | WINED3DUSAGE_QUERY_FILTER
5359 | WINED3DUSAGE_QUERY_GENMIPMAP
5360 | WINED3DUSAGE_QUERY_LEGACYBUMPMAP
5361 | WINED3DUSAGE_QUERY_SRGBREAD
5362 | WINED3DUSAGE_QUERY_SRGBWRITE
5363 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
5364 | WINED3DUSAGE_QUERY_WRAPANDMIP;
5365 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_2D;
5366 if (usage & WINED3DUSAGE_LEGACY_CUBEMAP)
5368 allowed_usage &= ~(WINED3DUSAGE_DEPTHSTENCIL | WINED3DUSAGE_QUERY_LEGACYBUMPMAP);
5369 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_CUBE;
5371 else if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
5372 && (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SHADOW)
5373 && !gl_info->supported[ARB_SHADOW])
5375 TRACE("[FAILED] - No shadow sampler support.\n");
5376 return WINED3DERR_NOTAVAILABLE;
5378 break;
5380 case WINED3D_RTYPE_TEXTURE_3D:
5381 allowed_usage = WINED3DUSAGE_DYNAMIC
5382 | WINED3DUSAGE_SOFTWAREPROCESSING
5383 | WINED3DUSAGE_TEXTURE
5384 | WINED3DUSAGE_QUERY_FILTER
5385 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
5386 | WINED3DUSAGE_QUERY_SRGBREAD
5387 | WINED3DUSAGE_QUERY_SRGBWRITE
5388 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
5389 | WINED3DUSAGE_QUERY_WRAPANDMIP;
5390 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D;
5391 break;
5393 default:
5394 FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type));
5395 return WINED3DERR_NOTAVAILABLE;
5398 if ((usage & allowed_usage) != usage)
5400 TRACE("Requested usage %#x, but resource type %s only allows %#x.\n",
5401 usage, debug_d3dresourcetype(resource_type), allowed_usage);
5402 return WINED3DERR_NOTAVAILABLE;
5405 if (usage & WINED3DUSAGE_TEXTURE)
5406 format_flags |= WINED3DFMT_FLAG_TEXTURE;
5407 if (usage & WINED3DUSAGE_QUERY_FILTER)
5408 format_flags |= WINED3DFMT_FLAG_FILTERING;
5409 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
5410 format_flags |= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
5411 if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
5412 format_flags |= WINED3DFMT_FLAG_SRGB_READ;
5413 if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
5414 format_flags |= WINED3DFMT_FLAG_SRGB_WRITE;
5415 if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
5416 format_flags |= WINED3DFMT_FLAG_VTF;
5417 if (usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP)
5418 format_flags |= WINED3DFMT_FLAG_BUMPMAP;
5420 if ((format_flags & WINED3DFMT_FLAG_TEXTURE) && (wined3d->flags & WINED3D_NO3D))
5422 TRACE("Requested texturing support, but wined3d was created with WINED3D_NO3D.\n");
5423 return WINED3DERR_NOTAVAILABLE;
5426 for (; gl_type <= gl_type_end; ++gl_type)
5428 if ((format->flags[gl_type] & format_flags) != format_flags)
5430 TRACE("Requested format flags %#x, but format %s only has %#x.\n",
5431 format_flags, debug_d3dformat(check_format_id), format->flags[gl_type]);
5432 return WINED3DERR_NOTAVAILABLE;
5435 if ((usage & WINED3DUSAGE_RENDERTARGET)
5436 && !CheckRenderTargetCapability(adapter, adapter_format, format, gl_type))
5438 TRACE("Requested WINED3DUSAGE_RENDERTARGET, but format %s is not supported for render targets.\n",
5439 debug_d3dformat(check_format_id));
5440 return WINED3DERR_NOTAVAILABLE;
5443 /* 3D depth / stencil textures are never supported. */
5444 if (usage == WINED3DUSAGE_DEPTHSTENCIL && gl_type == WINED3D_GL_RES_TYPE_TEX_3D)
5445 continue;
5447 if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
5448 && !CheckDepthStencilCapability(adapter, adapter_format, format, gl_type))
5450 TRACE("Requested WINED3DUSAGE_DEPTHSTENCIL, but format %s is not supported for depth / stencil buffers.\n",
5451 debug_d3dformat(check_format_id));
5452 return WINED3DERR_NOTAVAILABLE;
5455 if (!(format->flags[gl_type] & WINED3DFMT_FLAG_GEN_MIPMAP))
5456 mipmap_gen_supported = FALSE;
5459 if ((usage & WINED3DUSAGE_QUERY_GENMIPMAP) && !mipmap_gen_supported)
5461 TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n");
5462 return WINED3DOK_NOMIPGEN;
5465 return WINED3D_OK;
5468 UINT CDECL wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT adapter_idx,
5469 enum wined3d_format_id format_id, UINT width)
5471 const struct wined3d_gl_info *gl_info;
5472 unsigned int row_pitch, slice_pitch;
5474 TRACE("wined3d %p, adapter_idx %u, format_id %s, width %u.\n",
5475 wined3d, adapter_idx, debug_d3dformat(format_id), width);
5477 if (adapter_idx >= wined3d->adapter_count)
5478 return ~0u;
5480 gl_info = &wined3d->adapters[adapter_idx].gl_info;
5481 wined3d_format_calculate_pitch(wined3d_get_format(gl_info, format_id, 0),
5482 1, width, 1, &row_pitch, &slice_pitch);
5484 return row_pitch;
5487 HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d *wined3d, UINT adapter_idx,
5488 enum wined3d_device_type device_type, enum wined3d_format_id src_format, enum wined3d_format_id dst_format)
5490 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
5491 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(src_format),
5492 debug_d3dformat(dst_format));
5494 return WINED3D_OK;
5497 HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adapter_idx,
5498 enum wined3d_device_type device_type, enum wined3d_format_id display_format,
5499 enum wined3d_format_id backbuffer_format, BOOL windowed)
5501 BOOL present_conversion = wined3d->flags & WINED3D_PRESENT_CONVERSION;
5503 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
5504 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(display_format),
5505 debug_d3dformat(backbuffer_format), windowed);
5507 if (adapter_idx >= wined3d->adapter_count)
5508 return WINED3DERR_INVALIDCALL;
5510 /* The task of this function is to check whether a certain display / backbuffer format
5511 * combination is available on the given adapter. In fullscreen mode microsoft specified
5512 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
5513 * and display format should match exactly.
5514 * In windowed mode format conversion can occur and this depends on the driver. */
5516 /* There are only 4 display formats. */
5517 if (!(display_format == WINED3DFMT_B5G6R5_UNORM
5518 || display_format == WINED3DFMT_B5G5R5X1_UNORM
5519 || display_format == WINED3DFMT_B8G8R8X8_UNORM
5520 || display_format == WINED3DFMT_B10G10R10A2_UNORM))
5522 TRACE("Format %s is not supported as display format.\n", debug_d3dformat(display_format));
5523 return WINED3DERR_NOTAVAILABLE;
5526 if (!windowed)
5528 /* If the requested display format is not available, don't continue. */
5529 if (!wined3d_get_adapter_mode_count(wined3d, adapter_idx,
5530 display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN))
5532 TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format));
5533 return WINED3DERR_NOTAVAILABLE;
5536 present_conversion = FALSE;
5538 else if (display_format == WINED3DFMT_B10G10R10A2_UNORM)
5540 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode. */
5541 TRACE("Unsupported format combination %s / %s in windowed mode.\n",
5542 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5543 return WINED3DERR_NOTAVAILABLE;
5546 if (present_conversion)
5548 /* Use the display format as back buffer format if the latter is
5549 * WINED3DFMT_UNKNOWN. */
5550 if (backbuffer_format == WINED3DFMT_UNKNOWN)
5551 backbuffer_format = display_format;
5553 if (FAILED(wined3d_check_device_format_conversion(wined3d, adapter_idx,
5554 device_type, backbuffer_format, display_format)))
5556 TRACE("Format conversion from %s to %s not supported.\n",
5557 debug_d3dformat(backbuffer_format), debug_d3dformat(display_format));
5558 return WINED3DERR_NOTAVAILABLE;
5561 else
5563 /* When format conversion from the back buffer format to the display
5564 * format is not allowed, only a limited number of combinations are
5565 * valid. */
5567 if (display_format == WINED3DFMT_B5G6R5_UNORM && backbuffer_format != WINED3DFMT_B5G6R5_UNORM)
5569 TRACE("Unsupported format combination %s / %s.\n",
5570 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5571 return WINED3DERR_NOTAVAILABLE;
5574 if (display_format == WINED3DFMT_B5G5R5X1_UNORM
5575 && !(backbuffer_format == WINED3DFMT_B5G5R5X1_UNORM || backbuffer_format == WINED3DFMT_B5G5R5A1_UNORM))
5577 TRACE("Unsupported format combination %s / %s.\n",
5578 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5579 return WINED3DERR_NOTAVAILABLE;
5582 if (display_format == WINED3DFMT_B8G8R8X8_UNORM
5583 && !(backbuffer_format == WINED3DFMT_B8G8R8X8_UNORM || backbuffer_format == WINED3DFMT_B8G8R8A8_UNORM))
5585 TRACE("Unsupported format combination %s / %s.\n",
5586 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5587 return WINED3DERR_NOTAVAILABLE;
5590 if (display_format == WINED3DFMT_B10G10R10A2_UNORM
5591 && backbuffer_format != WINED3DFMT_B10G10R10A2_UNORM)
5593 TRACE("Unsupported format combination %s / %s.\n",
5594 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5595 return WINED3DERR_NOTAVAILABLE;
5599 /* Validate that the back buffer format is usable for render targets. */
5600 if (FAILED(wined3d_check_device_format(wined3d, adapter_idx, device_type, display_format,
5601 WINED3DUSAGE_RENDERTARGET, WINED3D_RTYPE_TEXTURE_2D, backbuffer_format)))
5603 TRACE("Format %s not allowed for render targets.\n", debug_d3dformat(backbuffer_format));
5604 return WINED3DERR_NOTAVAILABLE;
5607 return WINED3D_OK;
5610 HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapter_idx,
5611 enum wined3d_device_type device_type, WINED3DCAPS *caps)
5613 const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
5614 const struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
5615 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
5616 struct wined3d_vertex_caps vertex_caps;
5617 DWORD ckey_caps, blit_caps, fx_caps;
5618 struct fragment_caps fragment_caps;
5619 struct shader_caps shader_caps;
5621 TRACE("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
5622 wined3d, adapter_idx, debug_d3ddevicetype(device_type), caps);
5624 if (adapter_idx >= wined3d->adapter_count)
5625 return WINED3DERR_INVALIDCALL;
5627 caps->DeviceType = (device_type == WINED3D_DEVICE_TYPE_HAL) ? WINED3D_DEVICE_TYPE_HAL : WINED3D_DEVICE_TYPE_REF;
5628 caps->AdapterOrdinal = adapter_idx;
5630 caps->Caps = 0;
5631 caps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED |
5632 WINED3DCAPS2_FULLSCREENGAMMA |
5633 WINED3DCAPS2_DYNAMICTEXTURES;
5634 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT] || gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
5635 caps->Caps2 |= WINED3DCAPS2_CANGENMIPMAP;
5637 caps->Caps3 = WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD |
5638 WINED3DCAPS3_COPY_TO_VIDMEM |
5639 WINED3DCAPS3_COPY_TO_SYSTEMMEM;
5641 caps->CursorCaps = WINED3DCURSORCAPS_COLOR |
5642 WINED3DCURSORCAPS_LOWRES;
5644 caps->DevCaps = WINED3DDEVCAPS_FLOATTLVERTEX |
5645 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY |
5646 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY|
5647 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY |
5648 WINED3DDEVCAPS_DRAWPRIMTLVERTEX |
5649 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT |
5650 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY |
5651 WINED3DDEVCAPS_PUREDEVICE |
5652 WINED3DDEVCAPS_HWRASTERIZATION |
5653 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY |
5654 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY |
5655 WINED3DDEVCAPS_CANRENDERAFTERFLIP |
5656 WINED3DDEVCAPS_DRAWPRIMITIVES2 |
5657 WINED3DDEVCAPS_DRAWPRIMITIVES2EX;
5659 caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE |
5660 WINED3DPMISCCAPS_CULLCCW |
5661 WINED3DPMISCCAPS_CULLCW |
5662 WINED3DPMISCCAPS_COLORWRITEENABLE |
5663 WINED3DPMISCCAPS_CLIPTLVERTS |
5664 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
5665 WINED3DPMISCCAPS_MASKZ |
5666 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
5667 /* TODO:
5668 WINED3DPMISCCAPS_NULLREFERENCE
5669 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
5670 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
5671 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
5673 if (gl_info->supported[WINED3D_GL_BLEND_EQUATION])
5674 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_BLENDOP;
5675 if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
5676 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
5677 if (gl_info->supported[EXT_DRAW_BUFFERS2])
5678 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS;
5679 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB])
5680 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_POSTBLENDSRGBCONVERT;
5682 caps->RasterCaps = WINED3DPRASTERCAPS_DITHER |
5683 WINED3DPRASTERCAPS_PAT |
5684 WINED3DPRASTERCAPS_WFOG |
5685 WINED3DPRASTERCAPS_ZFOG |
5686 WINED3DPRASTERCAPS_FOGVERTEX |
5687 WINED3DPRASTERCAPS_FOGTABLE |
5688 WINED3DPRASTERCAPS_STIPPLE |
5689 WINED3DPRASTERCAPS_SUBPIXEL |
5690 WINED3DPRASTERCAPS_ZTEST |
5691 WINED3DPRASTERCAPS_SCISSORTEST |
5692 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
5693 WINED3DPRASTERCAPS_DEPTHBIAS;
5695 if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
5697 caps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY |
5698 WINED3DPRASTERCAPS_ZBIAS |
5699 WINED3DPRASTERCAPS_MIPMAPLODBIAS;
5702 caps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
5703 WINED3DPCMPCAPS_EQUAL |
5704 WINED3DPCMPCAPS_GREATER |
5705 WINED3DPCMPCAPS_GREATEREQUAL |
5706 WINED3DPCMPCAPS_LESS |
5707 WINED3DPCMPCAPS_LESSEQUAL |
5708 WINED3DPCMPCAPS_NEVER |
5709 WINED3DPCMPCAPS_NOTEQUAL;
5711 /* WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA
5712 * are legacy settings for srcblend only. */
5713 caps->SrcBlendCaps = WINED3DPBLENDCAPS_BOTHINVSRCALPHA |
5714 WINED3DPBLENDCAPS_BOTHSRCALPHA |
5715 WINED3DPBLENDCAPS_DESTALPHA |
5716 WINED3DPBLENDCAPS_DESTCOLOR |
5717 WINED3DPBLENDCAPS_INVDESTALPHA |
5718 WINED3DPBLENDCAPS_INVDESTCOLOR |
5719 WINED3DPBLENDCAPS_INVSRCALPHA |
5720 WINED3DPBLENDCAPS_INVSRCCOLOR |
5721 WINED3DPBLENDCAPS_ONE |
5722 WINED3DPBLENDCAPS_SRCALPHA |
5723 WINED3DPBLENDCAPS_SRCALPHASAT |
5724 WINED3DPBLENDCAPS_SRCCOLOR |
5725 WINED3DPBLENDCAPS_ZERO;
5727 caps->DestBlendCaps = WINED3DPBLENDCAPS_DESTALPHA |
5728 WINED3DPBLENDCAPS_DESTCOLOR |
5729 WINED3DPBLENDCAPS_INVDESTALPHA |
5730 WINED3DPBLENDCAPS_INVDESTCOLOR |
5731 WINED3DPBLENDCAPS_INVSRCALPHA |
5732 WINED3DPBLENDCAPS_INVSRCCOLOR |
5733 WINED3DPBLENDCAPS_ONE |
5734 WINED3DPBLENDCAPS_SRCALPHA |
5735 WINED3DPBLENDCAPS_SRCCOLOR |
5736 WINED3DPBLENDCAPS_ZERO;
5738 if (gl_info->supported[ARB_BLEND_FUNC_EXTENDED])
5739 caps->DestBlendCaps |= WINED3DPBLENDCAPS_SRCALPHASAT;
5741 if (gl_info->supported[EXT_BLEND_COLOR])
5743 caps->SrcBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
5744 caps->DestBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
5748 caps->AlphaCmpCaps = WINED3DPCMPCAPS_ALWAYS |
5749 WINED3DPCMPCAPS_EQUAL |
5750 WINED3DPCMPCAPS_GREATER |
5751 WINED3DPCMPCAPS_GREATEREQUAL |
5752 WINED3DPCMPCAPS_LESS |
5753 WINED3DPCMPCAPS_LESSEQUAL |
5754 WINED3DPCMPCAPS_NEVER |
5755 WINED3DPCMPCAPS_NOTEQUAL;
5757 caps->ShadeCaps = WINED3DPSHADECAPS_SPECULARGOURAUDRGB |
5758 WINED3DPSHADECAPS_COLORGOURAUDRGB |
5759 WINED3DPSHADECAPS_ALPHAFLATBLEND |
5760 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND |
5761 WINED3DPSHADECAPS_COLORFLATRGB |
5762 WINED3DPSHADECAPS_FOGFLAT |
5763 WINED3DPSHADECAPS_FOGGOURAUD |
5764 WINED3DPSHADECAPS_SPECULARFLATRGB;
5766 caps->TextureCaps = WINED3DPTEXTURECAPS_ALPHA |
5767 WINED3DPTEXTURECAPS_ALPHAPALETTE |
5768 WINED3DPTEXTURECAPS_TRANSPARENCY |
5769 WINED3DPTEXTURECAPS_BORDER |
5770 WINED3DPTEXTURECAPS_MIPMAP |
5771 WINED3DPTEXTURECAPS_PROJECTED |
5772 WINED3DPTEXTURECAPS_PERSPECTIVE;
5774 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
5776 caps->TextureCaps |= WINED3DPTEXTURECAPS_POW2;
5777 if (gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] || gl_info->supported[ARB_TEXTURE_RECTANGLE])
5778 caps->TextureCaps |= WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL;
5781 if (gl_info->supported[EXT_TEXTURE3D])
5783 caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP |
5784 WINED3DPTEXTURECAPS_MIPVOLUMEMAP;
5785 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
5787 caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2;
5791 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
5793 caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP |
5794 WINED3DPTEXTURECAPS_MIPCUBEMAP;
5795 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
5797 caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP_POW2;
5801 caps->TextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
5802 WINED3DPTFILTERCAPS_MAGFPOINT |
5803 WINED3DPTFILTERCAPS_MINFLINEAR |
5804 WINED3DPTFILTERCAPS_MINFPOINT |
5805 WINED3DPTFILTERCAPS_MIPFLINEAR |
5806 WINED3DPTFILTERCAPS_MIPFPOINT |
5807 WINED3DPTFILTERCAPS_LINEAR |
5808 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
5809 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
5810 WINED3DPTFILTERCAPS_MIPLINEAR |
5811 WINED3DPTFILTERCAPS_MIPNEAREST |
5812 WINED3DPTFILTERCAPS_NEAREST;
5814 if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
5816 caps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
5817 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
5820 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
5822 caps->CubeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
5823 WINED3DPTFILTERCAPS_MAGFPOINT |
5824 WINED3DPTFILTERCAPS_MINFLINEAR |
5825 WINED3DPTFILTERCAPS_MINFPOINT |
5826 WINED3DPTFILTERCAPS_MIPFLINEAR |
5827 WINED3DPTFILTERCAPS_MIPFPOINT |
5828 WINED3DPTFILTERCAPS_LINEAR |
5829 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
5830 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
5831 WINED3DPTFILTERCAPS_MIPLINEAR |
5832 WINED3DPTFILTERCAPS_MIPNEAREST |
5833 WINED3DPTFILTERCAPS_NEAREST;
5835 if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
5837 caps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
5838 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
5841 else
5843 caps->CubeTextureFilterCaps = 0;
5846 if (gl_info->supported[EXT_TEXTURE3D])
5848 caps->VolumeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
5849 WINED3DPTFILTERCAPS_MAGFPOINT |
5850 WINED3DPTFILTERCAPS_MINFLINEAR |
5851 WINED3DPTFILTERCAPS_MINFPOINT |
5852 WINED3DPTFILTERCAPS_MIPFLINEAR |
5853 WINED3DPTFILTERCAPS_MIPFPOINT |
5854 WINED3DPTFILTERCAPS_LINEAR |
5855 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
5856 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
5857 WINED3DPTFILTERCAPS_MIPLINEAR |
5858 WINED3DPTFILTERCAPS_MIPNEAREST |
5859 WINED3DPTFILTERCAPS_NEAREST;
5861 else
5863 caps->VolumeTextureFilterCaps = 0;
5866 caps->TextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
5867 WINED3DPTADDRESSCAPS_CLAMP |
5868 WINED3DPTADDRESSCAPS_WRAP;
5870 if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
5872 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
5874 if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
5876 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
5878 if (gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE])
5880 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
5883 if (gl_info->supported[EXT_TEXTURE3D])
5885 caps->VolumeTextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
5886 WINED3DPTADDRESSCAPS_CLAMP |
5887 WINED3DPTADDRESSCAPS_WRAP;
5888 if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
5890 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
5892 if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
5894 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
5896 if (gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE])
5898 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
5901 else
5903 caps->VolumeTextureAddressCaps = 0;
5906 caps->LineCaps = WINED3DLINECAPS_TEXTURE |
5907 WINED3DLINECAPS_ZTEST |
5908 WINED3DLINECAPS_BLEND |
5909 WINED3DLINECAPS_ALPHACMP |
5910 WINED3DLINECAPS_FOG;
5911 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
5912 * idea how generating the smoothing alpha values works; the result is different
5915 caps->MaxTextureWidth = gl_info->limits.texture_size;
5916 caps->MaxTextureHeight = gl_info->limits.texture_size;
5918 if (gl_info->supported[EXT_TEXTURE3D])
5919 caps->MaxVolumeExtent = gl_info->limits.texture3d_size;
5920 else
5921 caps->MaxVolumeExtent = 0;
5923 caps->MaxTextureRepeat = 32768;
5924 caps->MaxTextureAspectRatio = gl_info->limits.texture_size;
5925 caps->MaxVertexW = 1.0f;
5927 caps->GuardBandLeft = 0.0f;
5928 caps->GuardBandTop = 0.0f;
5929 caps->GuardBandRight = 0.0f;
5930 caps->GuardBandBottom = 0.0f;
5932 caps->ExtentsAdjust = 0.0f;
5934 caps->StencilCaps = WINED3DSTENCILCAPS_DECRSAT |
5935 WINED3DSTENCILCAPS_INCRSAT |
5936 WINED3DSTENCILCAPS_INVERT |
5937 WINED3DSTENCILCAPS_KEEP |
5938 WINED3DSTENCILCAPS_REPLACE |
5939 WINED3DSTENCILCAPS_ZERO;
5940 if (gl_info->supported[EXT_STENCIL_WRAP])
5942 caps->StencilCaps |= WINED3DSTENCILCAPS_DECR |
5943 WINED3DSTENCILCAPS_INCR;
5945 if (gl_info->supported[WINED3D_GL_VERSION_2_0] || gl_info->supported[EXT_STENCIL_TWO_SIDE]
5946 || gl_info->supported[ATI_SEPARATE_STENCIL])
5948 caps->StencilCaps |= WINED3DSTENCILCAPS_TWOSIDED;
5951 caps->MaxAnisotropy = gl_info->limits.anisotropy;
5952 caps->MaxPointSize = gl_info->limits.pointsize_max;
5954 caps->MaxPrimitiveCount = 0x555555; /* Taken from an AMD Radeon HD 5700 (Evergreen) GPU. */
5955 caps->MaxVertexIndex = 0xffffff; /* Taken from an AMD Radeon HD 5700 (Evergreen) GPU. */
5956 caps->MaxStreams = MAX_STREAMS;
5957 caps->MaxStreamStride = 1024;
5959 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
5960 caps->DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET |
5961 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
5962 caps->MaxNpatchTessellationLevel = 0;
5963 caps->MasterAdapterOrdinal = 0;
5964 caps->AdapterOrdinalInGroup = 0;
5965 caps->NumberOfAdaptersInGroup = 1;
5967 caps->NumSimultaneousRTs = gl_info->limits.buffers;
5969 caps->StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT |
5970 WINED3DPTFILTERCAPS_MAGFPOINT |
5971 WINED3DPTFILTERCAPS_MINFLINEAR |
5972 WINED3DPTFILTERCAPS_MAGFLINEAR;
5973 caps->VertexTextureFilterCaps = 0;
5975 adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
5976 adapter->fragment_pipe->get_caps(&adapter->gl_info, &fragment_caps);
5977 adapter->vertex_pipe->vp_get_caps(&adapter->gl_info, &vertex_caps);
5979 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
5980 caps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps;
5982 caps->VertexShaderVersion = shader_caps.vs_version;
5983 caps->MaxVertexShaderConst = shader_caps.vs_uniform_count;
5985 caps->PixelShaderVersion = shader_caps.ps_version;
5986 caps->PixelShader1xMaxValue = shader_caps.ps_1x_max_value;
5988 caps->TextureOpCaps = fragment_caps.TextureOpCaps;
5989 caps->MaxTextureBlendStages = fragment_caps.MaxTextureBlendStages;
5990 caps->MaxSimultaneousTextures = fragment_caps.MaxSimultaneousTextures;
5992 caps->MaxUserClipPlanes = vertex_caps.max_user_clip_planes;
5993 caps->MaxActiveLights = vertex_caps.max_active_lights;
5994 caps->MaxVertexBlendMatrices = vertex_caps.max_vertex_blend_matrices;
5995 caps->MaxVertexBlendMatrixIndex = vertex_caps.max_vertex_blend_matrix_index;
5996 caps->VertexProcessingCaps = vertex_caps.vertex_processing_caps;
5997 caps->FVFCaps = vertex_caps.fvf_caps;
5998 caps->RasterCaps |= vertex_caps.raster_caps;
6000 /* The following caps are shader specific, but they are things we cannot detect, or which
6001 * are the same among all shader models. So to avoid code duplication set the shader version
6002 * specific, but otherwise constant caps here
6004 if (caps->VertexShaderVersion >= 3)
6006 /* Where possible set the caps based on OpenGL extensions and if they
6007 * aren't set (in case of software rendering) use the VS 3.0 from
6008 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
6009 * VS3.0 value. */
6010 caps->VS20Caps.caps = WINED3DVS20CAPS_PREDICATION;
6011 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
6012 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH;
6013 caps->VS20Caps.temp_count = max(32, adapter->gl_info.limits.arb_vs_temps);
6014 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
6015 caps->VS20Caps.static_flow_control_depth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH;
6017 caps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
6018 caps->MaxVertexShader30InstructionSlots = max(512, adapter->gl_info.limits.arb_vs_instructions);
6019 caps->VertexTextureFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT | WINED3DPTFILTERCAPS_MAGFPOINT;
6021 else if (caps->VertexShaderVersion == 2)
6023 caps->VS20Caps.caps = 0;
6024 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
6025 caps->VS20Caps.temp_count = max(12, adapter->gl_info.limits.arb_vs_temps);
6026 caps->VS20Caps.static_flow_control_depth = 1;
6028 caps->MaxVShaderInstructionsExecuted = 65535;
6029 caps->MaxVertexShader30InstructionSlots = 0;
6031 else
6032 { /* VS 1.x */
6033 caps->VS20Caps.caps = 0;
6034 caps->VS20Caps.dynamic_flow_control_depth = 0;
6035 caps->VS20Caps.temp_count = 0;
6036 caps->VS20Caps.static_flow_control_depth = 0;
6038 caps->MaxVShaderInstructionsExecuted = 0;
6039 caps->MaxVertexShader30InstructionSlots = 0;
6042 if (caps->PixelShaderVersion >= 3)
6044 /* Where possible set the caps based on OpenGL extensions and if they
6045 * aren't set (in case of software rendering) use the PS 3.0 from
6046 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
6047 * PS 3.0 value. */
6049 /* Caps is more or less undocumented on MSDN but it appears to be
6050 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
6051 * cards from Windows */
6052 caps->PS20Caps.caps = WINED3DPS20CAPS_ARBITRARYSWIZZLE |
6053 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS |
6054 WINED3DPS20CAPS_PREDICATION |
6055 WINED3DPS20CAPS_NODEPENDENTREADLIMIT |
6056 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT;
6057 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
6058 caps->PS20Caps.dynamic_flow_control_depth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH;
6059 caps->PS20Caps.temp_count = max(32, adapter->gl_info.limits.arb_ps_temps);
6060 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
6061 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH;
6062 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
6063 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS;
6065 caps->MaxPShaderInstructionsExecuted = 65535;
6066 caps->MaxPixelShader30InstructionSlots = max(WINED3DMIN30SHADERINSTRUCTIONS,
6067 adapter->gl_info.limits.arb_ps_instructions);
6069 else if(caps->PixelShaderVersion == 2)
6071 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
6072 caps->PS20Caps.caps = 0;
6073 caps->PS20Caps.dynamic_flow_control_depth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
6074 caps->PS20Caps.temp_count = max(12, adapter->gl_info.limits.arb_ps_temps);
6075 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minimum: 1 */
6076 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
6077 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS;
6079 caps->MaxPShaderInstructionsExecuted = 512; /* Minimum value, a GeforceFX uses 1024 */
6080 caps->MaxPixelShader30InstructionSlots = 0;
6082 else /* PS 1.x */
6084 caps->PS20Caps.caps = 0;
6085 caps->PS20Caps.dynamic_flow_control_depth = 0;
6086 caps->PS20Caps.temp_count = 0;
6087 caps->PS20Caps.static_flow_control_depth = 0;
6088 caps->PS20Caps.instruction_slot_count = 0;
6090 caps->MaxPShaderInstructionsExecuted = 0;
6091 caps->MaxPixelShader30InstructionSlots = 0;
6094 if (caps->VertexShaderVersion >= 2)
6096 /* OpenGL supports all the formats below, perhaps not always
6097 * without conversion, but it supports them.
6098 * Further GLSL doesn't seem to have an official unsigned type so
6099 * don't advertise it yet as I'm not sure how we handle it.
6100 * We might need to add some clamping in the shader engine to
6101 * support it.
6102 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
6103 caps->DeclTypes = WINED3DDTCAPS_UBYTE4 |
6104 WINED3DDTCAPS_UBYTE4N |
6105 WINED3DDTCAPS_SHORT2N |
6106 WINED3DDTCAPS_SHORT4N;
6107 if (gl_info->supported[ARB_HALF_FLOAT_VERTEX])
6109 caps->DeclTypes |= WINED3DDTCAPS_FLOAT16_2 |
6110 WINED3DDTCAPS_FLOAT16_4;
6113 else
6115 caps->DeclTypes = 0;
6118 /* Set DirectDraw helper Caps */
6119 ckey_caps = WINEDDCKEYCAPS_DESTBLT |
6120 WINEDDCKEYCAPS_SRCBLT;
6121 fx_caps = WINEDDFXCAPS_BLTALPHA |
6122 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT |
6123 WINEDDFXCAPS_BLTMIRRORUPDOWN |
6124 WINEDDFXCAPS_BLTROTATION90 |
6125 WINEDDFXCAPS_BLTSHRINKX |
6126 WINEDDFXCAPS_BLTSHRINKXN |
6127 WINEDDFXCAPS_BLTSHRINKY |
6128 WINEDDFXCAPS_BLTSHRINKYN |
6129 WINEDDFXCAPS_BLTSTRETCHX |
6130 WINEDDFXCAPS_BLTSTRETCHXN |
6131 WINEDDFXCAPS_BLTSTRETCHY |
6132 WINEDDFXCAPS_BLTSTRETCHYN;
6133 blit_caps = WINEDDCAPS_BLT |
6134 WINEDDCAPS_BLTCOLORFILL |
6135 WINEDDCAPS_BLTDEPTHFILL |
6136 WINEDDCAPS_BLTSTRETCH |
6137 WINEDDCAPS_CANBLTSYSMEM |
6138 WINEDDCAPS_CANCLIP |
6139 WINEDDCAPS_CANCLIPSTRETCHED |
6140 WINEDDCAPS_COLORKEY |
6141 WINEDDCAPS_COLORKEYHWASSIST;
6143 /* Fill the ddraw caps structure */
6144 caps->ddraw_caps.caps = WINEDDCAPS_GDI |
6145 WINEDDCAPS_PALETTE |
6146 blit_caps;
6147 caps->ddraw_caps.caps2 = WINEDDCAPS2_CERTIFIED |
6148 WINEDDCAPS2_NOPAGELOCKREQUIRED |
6149 WINEDDCAPS2_PRIMARYGAMMA |
6150 WINEDDCAPS2_WIDESURFACES |
6151 WINEDDCAPS2_CANRENDERWINDOWED;
6152 caps->ddraw_caps.color_key_caps = ckey_caps;
6153 caps->ddraw_caps.fx_caps = fx_caps;
6154 caps->ddraw_caps.svb_caps = blit_caps;
6155 caps->ddraw_caps.svb_color_key_caps = ckey_caps;
6156 caps->ddraw_caps.svb_fx_caps = fx_caps;
6157 caps->ddraw_caps.vsb_caps = blit_caps;
6158 caps->ddraw_caps.vsb_color_key_caps = ckey_caps;
6159 caps->ddraw_caps.vsb_fx_caps = fx_caps;
6160 caps->ddraw_caps.ssb_caps = blit_caps;
6161 caps->ddraw_caps.ssb_color_key_caps = ckey_caps;
6162 caps->ddraw_caps.ssb_fx_caps = fx_caps;
6164 caps->ddraw_caps.dds_caps = WINEDDSCAPS_ALPHA |
6165 WINEDDSCAPS_BACKBUFFER |
6166 WINEDDSCAPS_FLIP |
6167 WINEDDSCAPS_FRONTBUFFER |
6168 WINEDDSCAPS_OFFSCREENPLAIN |
6169 WINEDDSCAPS_PALETTE |
6170 WINEDDSCAPS_PRIMARYSURFACE |
6171 WINEDDSCAPS_SYSTEMMEMORY |
6172 WINEDDSCAPS_VIDEOMEMORY |
6173 WINEDDSCAPS_VISIBLE;
6175 if (!(wined3d->flags & WINED3D_NO3D))
6177 caps->ddraw_caps.dds_caps |= WINEDDSCAPS_3DDEVICE |
6178 WINEDDSCAPS_MIPMAP |
6179 WINEDDSCAPS_TEXTURE |
6180 WINEDDSCAPS_ZBUFFER;
6181 caps->ddraw_caps.caps |= WINEDDCAPS_3D;
6184 caps->shader_double_precision = d3d_info->shader_double_precision;
6186 return WINED3D_OK;
6189 HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, enum wined3d_device_type device_type,
6190 HWND focus_window, DWORD flags, BYTE surface_alignment, struct wined3d_device_parent *device_parent,
6191 struct wined3d_device **device)
6193 struct wined3d_device *object;
6194 HRESULT hr;
6196 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, surface_alignment %u, device_parent %p, device %p.\n",
6197 wined3d, adapter_idx, device_type, focus_window, flags, surface_alignment, device_parent, device);
6199 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
6200 * number and create a device without a 3D adapter for 2D only operation. */
6201 if (wined3d->adapter_count && adapter_idx >= wined3d->adapter_count)
6202 return WINED3DERR_INVALIDCALL;
6204 if (!(object = heap_alloc_zero(sizeof(*object))))
6205 return E_OUTOFMEMORY;
6207 hr = device_init(object, wined3d, adapter_idx, device_type,
6208 focus_window, flags, surface_alignment, device_parent);
6209 if (FAILED(hr))
6211 WARN("Failed to initialize device, hr %#x.\n", hr);
6212 heap_free(object);
6213 return hr;
6216 TRACE("Created device %p.\n", object);
6217 *device = object;
6219 device_parent->ops->wined3d_device_created(device_parent, *device);
6221 return WINED3D_OK;
6224 static void WINE_GLAPI invalid_func(const void *data)
6226 ERR("Invalid vertex attribute function called.\n");
6227 DebugBreak();
6230 static void WINE_GLAPI invalid_texcoord_func(GLenum unit, const void *data)
6232 ERR("Invalid texcoord function called.\n");
6233 DebugBreak();
6236 static void WINE_GLAPI invalid_generic_attrib_func(GLuint idx, const void *data)
6238 ERR("Invalid attribute function called.\n");
6239 DebugBreak();
6242 /* Helper functions for providing vertex data to OpenGL. The arrays are
6243 * initialised based on the extension detection and are used in
6244 * draw_primitive_immediate_mode(). */
6245 static void WINE_GLAPI position_d3dcolor(const void *data)
6247 DWORD pos = *((const DWORD *)data);
6249 FIXME("Add a test for fixed function position from d3dcolor type.\n");
6250 context_get_current()->gl_info->gl_ops.gl.p_glVertex4s(D3DCOLOR_B_R(pos),
6251 D3DCOLOR_B_G(pos),
6252 D3DCOLOR_B_B(pos),
6253 D3DCOLOR_B_A(pos));
6256 static void WINE_GLAPI position_float4(const void *data)
6258 const GLfloat *pos = data;
6260 if (pos[3] != 0.0f && pos[3] != 1.0f)
6262 float w = 1.0f / pos[3];
6264 context_get_current()->gl_info->gl_ops.gl.p_glVertex4f(pos[0] * w, pos[1] * w, pos[2] * w, w);
6266 else
6268 context_get_current()->gl_info->gl_ops.gl.p_glVertex3fv(pos);
6272 static void WINE_GLAPI diffuse_d3dcolor(const void *data)
6274 DWORD diffuseColor = *((const DWORD *)data);
6276 context_get_current()->gl_info->gl_ops.gl.p_glColor4ub(D3DCOLOR_B_R(diffuseColor),
6277 D3DCOLOR_B_G(diffuseColor),
6278 D3DCOLOR_B_B(diffuseColor),
6279 D3DCOLOR_B_A(diffuseColor));
6282 static void WINE_GLAPI specular_d3dcolor(const void *data)
6284 DWORD specularColor = *((const DWORD *)data);
6285 GLubyte d[] =
6287 D3DCOLOR_B_R(specularColor),
6288 D3DCOLOR_B_G(specularColor),
6289 D3DCOLOR_B_B(specularColor)
6292 context_get_current()->gl_info->gl_ops.ext.p_glSecondaryColor3ubvEXT(d);
6295 static void WINE_GLAPI warn_no_specular_func(const void *data)
6297 WARN("GL_EXT_secondary_color not supported.\n");
6300 static void WINE_GLAPI generic_d3dcolor(GLuint idx, const void *data)
6302 DWORD color = *((const DWORD *)data);
6304 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4Nub(idx,
6305 D3DCOLOR_B_R(color), D3DCOLOR_B_G(color),
6306 D3DCOLOR_B_B(color), D3DCOLOR_B_A(color));
6309 static void WINE_GLAPI generic_short2n(GLuint idx, const void *data)
6311 const GLshort s[] = {((const GLshort *)data)[0], ((const GLshort *)data)[1], 0, 1};
6313 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4Nsv(idx, s);
6316 static void WINE_GLAPI generic_ushort2n(GLuint idx, const void *data)
6318 const GLushort s[] = {((const GLushort *)data)[0], ((const GLushort *)data)[1], 0, 1};
6320 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4Nusv(idx, s);
6323 static void WINE_GLAPI generic_float16_2(GLuint idx, const void *data)
6325 float x = float_16_to_32(((const unsigned short *)data) + 0);
6326 float y = float_16_to_32(((const unsigned short *)data) + 1);
6328 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib2f(idx, x, y);
6331 static void WINE_GLAPI generic_float16_4(GLuint idx, const void *data)
6333 float x = float_16_to_32(((const unsigned short *)data) + 0);
6334 float y = float_16_to_32(((const unsigned short *)data) + 1);
6335 float z = float_16_to_32(((const unsigned short *)data) + 2);
6336 float w = float_16_to_32(((const unsigned short *)data) + 3);
6338 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4f(idx, x, y, z, w);
6341 static void wined3d_adapter_init_ffp_attrib_ops(struct wined3d_adapter *adapter)
6343 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
6344 struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
6345 struct wined3d_ffp_attrib_ops *ops = &d3d_info->ffp_attrib_ops;
6346 unsigned int i;
6348 for (i = 0; i < WINED3D_FFP_EMIT_COUNT; ++i)
6350 ops->position[i] = invalid_func;
6351 ops->diffuse[i] = invalid_func;
6352 ops->specular[i] = invalid_func;
6353 ops->normal[i] = invalid_func;
6354 ops->texcoord[i] = invalid_texcoord_func;
6355 ops->generic[i] = invalid_generic_attrib_func;
6358 ops->position[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glVertex3fv;
6359 if (!d3d_info->xyzrhw)
6360 ops->position[WINED3D_FFP_EMIT_FLOAT4] = position_float4;
6361 else
6362 ops->position[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glVertex4fv;
6363 ops->position[WINED3D_FFP_EMIT_D3DCOLOR] = position_d3dcolor;
6364 ops->position[WINED3D_FFP_EMIT_SHORT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glVertex2sv;
6366 ops->diffuse[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor3fv;
6367 ops->diffuse[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4fv;
6368 ops->diffuse[WINED3D_FFP_EMIT_D3DCOLOR] = diffuse_d3dcolor;
6369 ops->diffuse[WINED3D_FFP_EMIT_UBYTE4N] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4ubv;
6370 ops->diffuse[WINED3D_FFP_EMIT_SHORT4N] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4sv;
6371 ops->diffuse[WINED3D_FFP_EMIT_USHORT4N] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4usv;
6373 /* No 4 component entry points here. */
6374 if (gl_info->supported[EXT_SECONDARY_COLOR])
6375 ops->specular[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)GL_EXTCALL(glSecondaryColor3fvEXT);
6376 else
6377 ops->specular[WINED3D_FFP_EMIT_FLOAT3] = warn_no_specular_func;
6378 if (gl_info->supported[EXT_SECONDARY_COLOR])
6379 ops->specular[WINED3D_FFP_EMIT_D3DCOLOR] = specular_d3dcolor;
6380 else
6381 ops->specular[WINED3D_FFP_EMIT_D3DCOLOR] = warn_no_specular_func;
6383 /* Only 3 component entry points here. Test how others behave. Float4
6384 * normals are used by one of our tests, trying to pass it to the pixel
6385 * shader, which fails on Windows. */
6386 ops->normal[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glNormal3fv;
6387 /* Just ignore the 4th value. */
6388 ops->normal[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glNormal3fv;
6390 ops->texcoord[WINED3D_FFP_EMIT_FLOAT1] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord1fvARB;
6391 ops->texcoord[WINED3D_FFP_EMIT_FLOAT2] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord2fvARB;
6392 ops->texcoord[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord3fvARB;
6393 ops->texcoord[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord4fvARB;
6394 ops->texcoord[WINED3D_FFP_EMIT_SHORT2] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord2svARB;
6395 ops->texcoord[WINED3D_FFP_EMIT_SHORT4] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord4svARB;
6396 if (gl_info->supported[NV_HALF_FLOAT])
6398 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT. */
6399 ops->texcoord[WINED3D_FFP_EMIT_FLOAT16_2] =
6400 (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord2hvNV;
6401 ops->texcoord[WINED3D_FFP_EMIT_FLOAT16_4] =
6402 (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord4hvNV;
6405 ops->generic[WINED3D_FFP_EMIT_FLOAT1] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib1fv;
6406 ops->generic[WINED3D_FFP_EMIT_FLOAT2] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2fv;
6407 ops->generic[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib3fv;
6408 ops->generic[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4fv;
6409 if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
6410 ops->generic[WINED3D_FFP_EMIT_D3DCOLOR] = generic_d3dcolor;
6411 else
6412 ops->generic[WINED3D_FFP_EMIT_D3DCOLOR] =
6413 (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nubv;
6414 ops->generic[WINED3D_FFP_EMIT_UBYTE4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4ubv;
6415 ops->generic[WINED3D_FFP_EMIT_SHORT2] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2sv;
6416 ops->generic[WINED3D_FFP_EMIT_SHORT4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4sv;
6417 ops->generic[WINED3D_FFP_EMIT_UBYTE4N] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nubv;
6418 ops->generic[WINED3D_FFP_EMIT_SHORT2N] = generic_short2n;
6419 ops->generic[WINED3D_FFP_EMIT_SHORT4N] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nsv;
6420 ops->generic[WINED3D_FFP_EMIT_USHORT2N] = generic_ushort2n;
6421 ops->generic[WINED3D_FFP_EMIT_USHORT4N] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nusv;
6422 if (gl_info->supported[NV_HALF_FLOAT] && gl_info->supported[NV_VERTEX_PROGRAM])
6424 ops->generic[WINED3D_FFP_EMIT_FLOAT16_2] =
6425 (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2hvNV;
6426 ops->generic[WINED3D_FFP_EMIT_FLOAT16_4] =
6427 (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4hvNV;
6429 else
6431 ops->generic[WINED3D_FFP_EMIT_FLOAT16_2] = generic_float16_2;
6432 ops->generic[WINED3D_FFP_EMIT_FLOAT16_4] = generic_float16_4;
6436 static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter *adapter, HDC dc)
6438 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
6439 int i;
6441 if (gl_info->supported[WGL_ARB_PIXEL_FORMAT])
6443 UINT attrib_count = 0;
6444 GLint cfg_count;
6445 int attribs[11];
6446 int values[11];
6447 int attribute;
6449 attribute = WGL_NUMBER_PIXEL_FORMATS_ARB;
6450 GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, 0, 0, 1, &attribute, &cfg_count));
6452 adapter->cfgs = heap_calloc(cfg_count, sizeof(*adapter->cfgs));
6453 attribs[attrib_count++] = WGL_RED_BITS_ARB;
6454 attribs[attrib_count++] = WGL_GREEN_BITS_ARB;
6455 attribs[attrib_count++] = WGL_BLUE_BITS_ARB;
6456 attribs[attrib_count++] = WGL_ALPHA_BITS_ARB;
6457 attribs[attrib_count++] = WGL_COLOR_BITS_ARB;
6458 attribs[attrib_count++] = WGL_DEPTH_BITS_ARB;
6459 attribs[attrib_count++] = WGL_STENCIL_BITS_ARB;
6460 attribs[attrib_count++] = WGL_DRAW_TO_WINDOW_ARB;
6461 attribs[attrib_count++] = WGL_PIXEL_TYPE_ARB;
6462 attribs[attrib_count++] = WGL_DOUBLE_BUFFER_ARB;
6463 attribs[attrib_count++] = WGL_AUX_BUFFERS_ARB;
6465 for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
6467 struct wined3d_pixel_format *cfg = &adapter->cfgs[adapter->cfg_count];
6468 int format_id = i + 1;
6470 if (!GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, format_id, 0, attrib_count, attribs, values)))
6471 continue;
6473 cfg->iPixelFormat = format_id;
6474 cfg->redSize = values[0];
6475 cfg->greenSize = values[1];
6476 cfg->blueSize = values[2];
6477 cfg->alphaSize = values[3];
6478 cfg->colorSize = values[4];
6479 cfg->depthSize = values[5];
6480 cfg->stencilSize = values[6];
6481 cfg->windowDrawable = values[7];
6482 cfg->iPixelType = values[8];
6483 cfg->doubleBuffer = values[9];
6484 cfg->auxBuffers = values[10];
6486 cfg->numSamples = 0;
6487 /* Check multisample support. */
6488 if (gl_info->supported[ARB_MULTISAMPLE])
6490 int attribs[2] = {WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB};
6491 int values[2];
6493 if (GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, format_id, 0, 2, attribs, values)))
6495 /* values[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether
6496 * multisampling is supported. values[1] = number of
6497 * multisample buffers. */
6498 if (values[0])
6499 cfg->numSamples = values[1];
6503 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
6504 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
6505 cfg->iPixelFormat, cfg->iPixelType, cfg->doubleBuffer,
6506 cfg->redSize, cfg->greenSize, cfg->blueSize, cfg->alphaSize,
6507 cfg->depthSize, cfg->stencilSize, cfg->numSamples, cfg->windowDrawable);
6509 ++adapter->cfg_count;
6512 else
6514 int cfg_count;
6516 cfg_count = DescribePixelFormat(dc, 0, 0, 0);
6517 adapter->cfgs = heap_calloc(cfg_count, sizeof(*adapter->cfgs));
6519 for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
6521 struct wined3d_pixel_format *cfg = &adapter->cfgs[adapter->cfg_count];
6522 PIXELFORMATDESCRIPTOR pfd;
6523 int format_id = i + 1;
6525 if (!DescribePixelFormat(dc, format_id, sizeof(pfd), &pfd))
6526 continue;
6528 /* We only want HW acceleration using an OpenGL ICD driver.
6529 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering.
6530 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD
6531 * driver (e.g. 3dfx minigl). */
6532 if (pfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED))
6534 TRACE("Skipping format %d because it isn't ICD accelerated.\n", format_id);
6535 continue;
6538 cfg->iPixelFormat = format_id;
6539 cfg->redSize = pfd.cRedBits;
6540 cfg->greenSize = pfd.cGreenBits;
6541 cfg->blueSize = pfd.cBlueBits;
6542 cfg->alphaSize = pfd.cAlphaBits;
6543 cfg->colorSize = pfd.cColorBits;
6544 cfg->depthSize = pfd.cDepthBits;
6545 cfg->stencilSize = pfd.cStencilBits;
6546 cfg->windowDrawable = (pfd.dwFlags & PFD_DRAW_TO_WINDOW) ? 1 : 0;
6547 cfg->iPixelType = (pfd.iPixelType == PFD_TYPE_RGBA) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB;
6548 cfg->doubleBuffer = (pfd.dwFlags & PFD_DOUBLEBUFFER) ? 1 : 0;
6549 cfg->auxBuffers = pfd.cAuxBuffers;
6550 cfg->numSamples = 0;
6552 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
6553 "depth=%d, stencil=%d, windowDrawable=%d\n",
6554 cfg->iPixelFormat, cfg->iPixelType, cfg->doubleBuffer,
6555 cfg->redSize, cfg->greenSize, cfg->blueSize, cfg->alphaSize,
6556 cfg->depthSize, cfg->stencilSize, cfg->windowDrawable);
6558 ++adapter->cfg_count;
6563 static DWORD get_max_gl_version(const struct wined3d_gl_info *gl_info, DWORD flags)
6565 const char *gl_vendor, *gl_renderer;
6567 if (wined3d_settings.explicit_gl_version || (flags & WINED3D_PIXEL_CENTER_INTEGER))
6568 return wined3d_settings.max_gl_version;
6570 gl_vendor = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VENDOR);
6571 gl_renderer = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER);
6572 if (!gl_vendor || !gl_renderer
6573 || wined3d_guess_card_vendor(gl_vendor, gl_renderer) == HW_VENDOR_NVIDIA)
6574 return wined3d_settings.max_gl_version;
6576 return MAKEDWORD_VERSION(4, 4);
6579 static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal, DWORD wined3d_creation_flags)
6581 static const DWORD supported_gl_versions[] =
6583 MAKEDWORD_VERSION(4, 4),
6584 MAKEDWORD_VERSION(3, 2),
6585 MAKEDWORD_VERSION(1, 0),
6587 struct wined3d_gl_info *gl_info = &adapter->gl_info;
6588 struct wined3d_caps_gl_ctx caps_gl_ctx = {0};
6589 unsigned int i;
6590 DISPLAY_DEVICEW display_device;
6591 DWORD max_gl_version;
6593 TRACE("adapter %p, ordinal %u.\n", adapter, ordinal);
6595 adapter->ordinal = ordinal;
6597 /* Dynamically load all GL core functions */
6598 #ifdef USE_WIN32_OPENGL
6600 HMODULE mod_gl = GetModuleHandleA("opengl32.dll");
6601 #define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
6602 ALL_WGL_FUNCS
6603 #undef USE_GL_FUNC
6604 gl_info->gl_ops.wgl.p_wglSwapBuffers = (void *)GetProcAddress(mod_gl, "wglSwapBuffers");
6605 gl_info->gl_ops.wgl.p_wglGetPixelFormat = (void *)GetProcAddress(mod_gl, "wglGetPixelFormat");
6607 #else
6608 /* To bypass the opengl32 thunks retrieve functions from the WGL driver instead of opengl32 */
6610 HDC hdc = GetDC( 0 );
6611 const struct opengl_funcs *wgl_driver = __wine_get_wgl_driver( hdc, WINE_WGL_DRIVER_VERSION );
6612 ReleaseDC( 0, hdc );
6613 if (!wgl_driver || wgl_driver == (void *)-1) return FALSE;
6614 gl_info->gl_ops.wgl = wgl_driver->wgl;
6615 gl_info->gl_ops.gl = wgl_driver->gl;
6617 #endif
6619 glEnableWINE = gl_info->gl_ops.gl.p_glEnable;
6620 glDisableWINE = gl_info->gl_ops.gl.p_glDisable;
6622 if (!AllocateLocallyUniqueId(&adapter->luid))
6624 ERR("Failed to set adapter LUID (%#x).\n", GetLastError());
6625 return FALSE;
6627 TRACE("Allocated LUID %08x:%08x for adapter %p.\n",
6628 adapter->luid.HighPart, adapter->luid.LowPart, adapter);
6630 if (!wined3d_caps_gl_ctx_create(adapter, &caps_gl_ctx))
6632 ERR("Failed to get a GL context for adapter %p.\n", adapter);
6633 return FALSE;
6636 max_gl_version = get_max_gl_version(gl_info, wined3d_creation_flags);
6637 for (i = 0; i < ARRAY_SIZE(supported_gl_versions); ++i)
6639 if (supported_gl_versions[i] <= max_gl_version)
6640 break;
6642 if (i == ARRAY_SIZE(supported_gl_versions))
6644 ERR_(winediag)("Requested invalid GL version %u.%u.\n",
6645 max_gl_version >> 16, max_gl_version & 0xffff);
6646 i = ARRAY_SIZE(supported_gl_versions) - 1;
6649 for (; i < ARRAY_SIZE(supported_gl_versions); ++i)
6651 gl_info->selected_gl_version = supported_gl_versions[i];
6653 if (wined3d_caps_gl_ctx_create_attribs(&caps_gl_ctx, gl_info))
6654 break;
6656 WARN("Couldn't create an OpenGL %u.%u context, trying fallback to a lower version.\n",
6657 supported_gl_versions[i] >> 16, supported_gl_versions[i] & 0xffff);
6660 if (!wined3d_adapter_init_gl_caps(adapter, &caps_gl_ctx, wined3d_creation_flags))
6662 ERR("Failed to initialize GL caps for adapter %p.\n", adapter);
6663 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
6664 return FALSE;
6667 if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
6668 ERR_(winediag)("You are using the backbuffer for offscreen rendering. "
6669 "This is unsupported, and will be removed in a future version.\n");
6671 wined3d_adapter_init_fb_cfgs(adapter, caps_gl_ctx.dc);
6672 /* We haven't found any suitable formats. This should only happen in
6673 * case of GDI software rendering, which is pretty useless anyway. */
6674 if (!adapter->cfg_count)
6676 WARN("No suitable pixel formats found.\n");
6677 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
6678 heap_free(adapter->cfgs);
6679 return FALSE;
6682 if (!wined3d_adapter_init_format_info(adapter, &caps_gl_ctx))
6684 ERR("Failed to initialize GL format info.\n");
6685 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
6686 heap_free(adapter->cfgs);
6687 return FALSE;
6690 adapter->vram_bytes = adapter->driver_info.vram_bytes;
6691 adapter->vram_bytes_used = 0;
6692 TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes));
6694 display_device.cb = sizeof(display_device);
6695 EnumDisplayDevicesW(NULL, ordinal, &display_device, 0);
6696 TRACE("DeviceName: %s\n", debugstr_w(display_device.DeviceName));
6697 strcpyW(adapter->DeviceName, display_device.DeviceName);
6699 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
6701 wined3d_adapter_init_ffp_attrib_ops(adapter);
6703 return TRUE;
6706 static BOOL wined3d_adapter_init_nogl(struct wined3d_adapter *adapter, UINT ordinal)
6708 DISPLAY_DEVICEW display_device;
6710 memset(adapter, 0, sizeof(*adapter));
6711 adapter->ordinal = ordinal;
6713 adapter->driver_info.name = "Display";
6714 adapter->driver_info.description = "WineD3D DirectDraw Emulation";
6715 if (wined3d_settings.emulated_textureram)
6716 adapter->vram_bytes = wined3d_settings.emulated_textureram;
6717 else
6718 adapter->vram_bytes = 128 * 1024 * 1024;
6720 if (!wined3d_adapter_init_format_info(adapter, NULL))
6721 return FALSE;
6723 adapter->vertex_pipe = &none_vertex_pipe;
6724 adapter->fragment_pipe = &none_fragment_pipe;
6725 adapter->shader_backend = &none_shader_backend;
6727 display_device.cb = sizeof(display_device);
6728 EnumDisplayDevicesW(NULL, ordinal, &display_device, 0);
6729 TRACE("DeviceName: %s\n", debugstr_w(display_device.DeviceName));
6730 strcpyW(adapter->DeviceName, display_device.DeviceName);
6732 return TRUE;
6735 static void STDMETHODCALLTYPE wined3d_null_wined3d_object_destroyed(void *parent) {}
6737 const struct wined3d_parent_ops wined3d_null_parent_ops =
6739 wined3d_null_wined3d_object_destroyed,
6742 HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags)
6744 BOOL ret;
6746 wined3d->ref = 1;
6747 wined3d->flags = flags;
6749 TRACE("Initializing adapters.\n");
6751 if (flags & WINED3D_NO3D)
6752 ret = wined3d_adapter_init_nogl(&wined3d->adapters[0], 0);
6753 else
6754 ret = wined3d_adapter_init(&wined3d->adapters[0], 0, flags);
6755 if (!ret)
6757 WARN("Failed to initialize adapter.\n");
6758 return E_FAIL;
6760 wined3d->adapter_count = 1;
6762 return WINED3D_OK;