webservices: Add support for union types in the writer.
[wine.git] / dlls / wined3d / directx.c
blob9707f81a3b51ff21e7466c436c3c5ccf63783fcb
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_blend_func_extended", ARB_BLEND_FUNC_EXTENDED },
113 {"GL_ARB_clear_buffer_object", ARB_CLEAR_BUFFER_OBJECT },
114 {"GL_ARB_clear_texture", ARB_CLEAR_TEXTURE },
115 {"GL_ARB_clip_control", ARB_CLIP_CONTROL },
116 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT },
117 {"GL_ARB_compute_shader", ARB_COMPUTE_SHADER },
118 {"GL_ARB_copy_buffer", ARB_COPY_BUFFER },
119 {"GL_ARB_debug_output", ARB_DEBUG_OUTPUT },
120 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT },
121 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE },
122 {"GL_ARB_derivative_control", ARB_DERIVATIVE_CONTROL },
123 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS },
124 {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX },
125 {"GL_ARB_draw_instanced", ARB_DRAW_INSTANCED },
126 {"GL_ARB_ES2_compatibility", ARB_ES2_COMPATIBILITY },
127 {"GL_ARB_ES3_compatibility", ARB_ES3_COMPATIBILITY },
128 {"GL_ARB_explicit_attrib_location", ARB_EXPLICIT_ATTRIB_LOCATION },
129 {"GL_ARB_fragment_coord_conventions", ARB_FRAGMENT_COORD_CONVENTIONS},
130 {"GL_ARB_fragment_layer_viewport", ARB_FRAGMENT_LAYER_VIEWPORT },
131 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM },
132 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER },
133 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT },
134 {"GL_ARB_framebuffer_sRGB", ARB_FRAMEBUFFER_SRGB },
135 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4 },
136 {"GL_ARB_gpu_shader5", ARB_GPU_SHADER5 },
137 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL },
138 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX },
139 {"GL_ARB_instanced_arrays", ARB_INSTANCED_ARRAYS },
140 {"GL_ARB_internalformat_query", ARB_INTERNALFORMAT_QUERY },
141 {"GL_ARB_internalformat_query2", ARB_INTERNALFORMAT_QUERY2 },
142 {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT },
143 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE },
144 {"GL_ARB_multisample", ARB_MULTISAMPLE },
145 {"GL_ARB_multitexture", ARB_MULTITEXTURE },
146 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY },
147 {"GL_ARB_pipeline_statistics_query", ARB_PIPELINE_STATISTICS_QUERY },
148 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT },
149 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS },
150 {"GL_ARB_point_sprite", ARB_POINT_SPRITE },
151 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX },
152 {"GL_ARB_sampler_objects", ARB_SAMPLER_OBJECTS },
153 {"GL_ARB_seamless_cube_map", ARB_SEAMLESS_CUBE_MAP },
154 {"GL_ARB_shader_atomic_counters", ARB_SHADER_ATOMIC_COUNTERS },
155 {"GL_ARB_shader_bit_encoding", ARB_SHADER_BIT_ENCODING },
156 {"GL_ARB_shader_image_load_store", ARB_SHADER_IMAGE_LOAD_STORE },
157 {"GL_ARB_shader_image_size", ARB_SHADER_IMAGE_SIZE },
158 {"GL_ARB_shader_storage_buffer_object", ARB_SHADER_STORAGE_BUFFER_OBJECT},
159 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD },
160 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100 },
161 {"GL_ARB_shading_language_420pack", ARB_SHADING_LANGUAGE_420PACK },
162 {"GL_ARB_shading_language_packing", ARB_SHADING_LANGUAGE_PACKING },
163 {"GL_ARB_shadow", ARB_SHADOW },
164 {"GL_ARB_stencil_texturing", ARB_STENCIL_TEXTURING },
165 {"GL_ARB_sync", ARB_SYNC },
166 {"GL_ARB_tessellation_shader", ARB_TESSELLATION_SHADER },
167 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP },
168 {"GL_ARB_texture_buffer_object", ARB_TEXTURE_BUFFER_OBJECT },
169 {"GL_ARB_texture_buffer_range", ARB_TEXTURE_BUFFER_RANGE },
170 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION },
171 {"GL_ARB_texture_compression_bptc", ARB_TEXTURE_COMPRESSION_BPTC },
172 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC },
173 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP },
174 {"GL_ARB_texture_cube_map_array", ARB_TEXTURE_CUBE_MAP_ARRAY },
175 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE },
176 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3 },
177 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT },
178 {"GL_ARB_texture_gather", ARB_TEXTURE_GATHER },
179 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT },
180 {"GL_ARB_texture_mirror_clamp_to_edge", ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE},
181 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO },
182 {"GL_ARB_texture_query_levels", ARB_TEXTURE_QUERY_LEVELS },
183 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE },
184 {"GL_ARB_texture_rg", ARB_TEXTURE_RG },
185 {"GL_ARB_texture_rgb10_a2ui", ARB_TEXTURE_RGB10_A2UI },
186 {"GL_ARB_texture_storage", ARB_TEXTURE_STORAGE },
187 {"GL_ARB_texture_swizzle", ARB_TEXTURE_SWIZZLE },
188 {"GL_ARB_texture_view", ARB_TEXTURE_VIEW },
189 {"GL_ARB_timer_query", ARB_TIMER_QUERY },
190 {"GL_ARB_transform_feedback2", ARB_TRANSFORM_FEEDBACK2 },
191 {"GL_ARB_transform_feedback3", ARB_TRANSFORM_FEEDBACK3 },
192 {"GL_ARB_uniform_buffer_object", ARB_UNIFORM_BUFFER_OBJECT },
193 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA },
194 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND },
195 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT },
196 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM },
197 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER },
198 {"GL_ARB_vertex_type_2_10_10_10_rev", ARB_VERTEX_TYPE_2_10_10_10_REV},
199 {"GL_ARB_viewport_array", ARB_VIEWPORT_ARRAY },
201 /* ATI */
202 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER },
203 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL },
204 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC },
205 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3 },
206 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE },
208 /* EXT */
209 {"GL_EXT_blend_color", EXT_BLEND_COLOR },
210 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE },
211 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE },
212 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX },
213 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT },
214 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST },
215 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2 },
216 {"GL_EXT_fog_coord", EXT_FOG_COORD },
217 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT },
218 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE },
219 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT },
220 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS },
221 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4 },
222 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL },
223 {"GL_EXT_packed_float", EXT_PACKED_FLOAT },
224 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS },
225 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX },
226 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR },
227 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE },
228 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP },
229 {"GL_EXT_texture3D", EXT_TEXTURE3D },
230 {"GL_EXT_texture_array", EXT_TEXTURE_ARRAY },
231 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC },
232 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC },
233 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE },
234 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3 },
235 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC},
236 {"GL_EXT_texture_integer", EXT_TEXTURE_INTEGER },
237 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS },
238 {"GL_EXT_texture_mirror_clamp", EXT_TEXTURE_MIRROR_CLAMP },
239 {"GL_EXT_texture_shared_exponent", EXT_TEXTURE_SHARED_EXPONENT },
240 {"GL_EXT_texture_snorm", EXT_TEXTURE_SNORM },
241 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB },
242 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE },
243 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA },
245 /* NV */
246 {"GL_NV_fence", NV_FENCE },
247 {"GL_NV_fog_distance", NV_FOG_DISTANCE },
248 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM },
249 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2 },
250 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION },
251 {"GL_NV_half_float", NV_HALF_FLOAT },
252 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT },
253 {"GL_NV_point_sprite", NV_POINT_SPRITE },
254 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS },
255 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2 },
256 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION },
257 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4 },
258 {"GL_NV_texture_shader", NV_TEXTURE_SHADER },
259 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2 },
260 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM },
261 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1 },
262 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2 },
263 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION },
264 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3 },
266 /* SGI */
267 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP },
270 static const struct wined3d_extension_map wgl_extension_map[] =
272 {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT },
273 {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL },
274 {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH},
275 {"WGL_WINE_query_renderer", WGL_WINE_QUERY_RENDERER },
278 /**********************************************************
279 * Utility functions follow
280 **********************************************************/
282 const struct min_lookup minMipLookup[] =
284 /* NONE POINT LINEAR */
285 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
286 {{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
287 {{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
290 const GLenum magLookup[] =
292 /* NONE POINT LINEAR */
293 GL_NEAREST, GL_NEAREST, GL_LINEAR,
296 static void wined3d_caps_gl_ctx_destroy(const struct wined3d_caps_gl_ctx *ctx)
298 const struct wined3d_gl_info *gl_info = ctx->gl_info;
300 TRACE("Destroying caps GL context.\n");
302 /* Both glDeleteProgram and glDeleteBuffers silently ignore 0 IDs but
303 * this function might be called before the relevant function pointers
304 * in gl_info are initialized. */
305 if (ctx->test_program_id || ctx->test_vbo)
307 GL_EXTCALL(glDeleteProgram(ctx->test_program_id));
308 GL_EXTCALL(glDeleteBuffers(1, &ctx->test_vbo));
311 if (!wglMakeCurrent(NULL, NULL))
312 ERR("Failed to disable caps GL context.\n");
314 if (!wglDeleteContext(ctx->gl_ctx))
316 DWORD err = GetLastError();
317 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx->gl_ctx, err);
320 wined3d_release_dc(ctx->wnd, ctx->dc);
321 DestroyWindow(ctx->wnd);
323 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
324 ERR("Failed to restore previous GL context.\n");
327 static BOOL wined3d_caps_gl_ctx_create_attribs(struct wined3d_caps_gl_ctx *caps_gl_ctx,
328 struct wined3d_gl_info *gl_info)
330 HGLRC new_ctx;
332 if (!(gl_info->p_wglCreateContextAttribsARB = (void *)wglGetProcAddress("wglCreateContextAttribsARB")))
333 return TRUE;
335 if (!(new_ctx = context_create_wgl_attribs(gl_info, caps_gl_ctx->dc, NULL)))
337 gl_info->p_wglCreateContextAttribsARB = NULL;
338 return FALSE;
341 if (!wglMakeCurrent(caps_gl_ctx->dc, new_ctx))
343 ERR("Failed to make new context current, last error %#x.\n", GetLastError());
344 if (!wglDeleteContext(new_ctx))
345 ERR("Failed to delete new context, last error %#x.\n", GetLastError());
346 gl_info->p_wglCreateContextAttribsARB = NULL;
347 return TRUE;
350 if (!wglDeleteContext(caps_gl_ctx->gl_ctx))
351 ERR("Failed to delete old context, last error %#x.\n", GetLastError());
352 caps_gl_ctx->gl_ctx = new_ctx;
354 return TRUE;
357 static BOOL wined3d_caps_gl_ctx_create(struct wined3d_adapter *adapter, struct wined3d_caps_gl_ctx *ctx)
359 PIXELFORMATDESCRIPTOR pfd;
360 int iPixelFormat;
362 TRACE("getting context...\n");
364 ctx->restore_dc = wglGetCurrentDC();
365 ctx->restore_gl_ctx = wglGetCurrentContext();
367 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
368 ctx->wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
369 WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL);
370 if (!ctx->wnd)
372 ERR("Failed to create a window.\n");
373 goto fail;
376 ctx->dc = GetDC(ctx->wnd);
377 if (!ctx->dc)
379 ERR("Failed to get a DC.\n");
380 goto fail;
383 /* PixelFormat selection */
384 ZeroMemory(&pfd, sizeof(pfd));
385 pfd.nSize = sizeof(pfd);
386 pfd.nVersion = 1;
387 pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW; /* PFD_GENERIC_ACCELERATED */
388 pfd.iPixelType = PFD_TYPE_RGBA;
389 pfd.cColorBits = 32;
390 pfd.iLayerType = PFD_MAIN_PLANE;
392 if (!(iPixelFormat = ChoosePixelFormat(ctx->dc, &pfd)))
394 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
395 ERR("Failed to find a suitable pixel format.\n");
396 goto fail;
398 DescribePixelFormat(ctx->dc, iPixelFormat, sizeof(pfd), &pfd);
399 SetPixelFormat(ctx->dc, iPixelFormat, &pfd);
401 /* Create a GL context. */
402 if (!(ctx->gl_ctx = wglCreateContext(ctx->dc)))
404 WARN("Failed to create default context for capabilities initialization.\n");
405 goto fail;
408 /* Make it the current GL context. */
409 if (!wglMakeCurrent(ctx->dc, ctx->gl_ctx))
411 ERR("Failed to make caps GL context current.\n");
412 goto fail;
415 ctx->gl_info = &adapter->gl_info;
416 return TRUE;
418 fail:
419 if (ctx->gl_ctx) wglDeleteContext(ctx->gl_ctx);
420 ctx->gl_ctx = NULL;
421 if (ctx->dc) ReleaseDC(ctx->wnd, ctx->dc);
422 ctx->dc = NULL;
423 if (ctx->wnd) DestroyWindow(ctx->wnd);
424 ctx->wnd = NULL;
425 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
426 ERR("Failed to restore previous GL context.\n");
428 return FALSE;
431 /* Adjust the amount of used texture memory */
432 UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount)
434 adapter->vram_bytes_used += amount;
435 TRACE("Adjusted used adapter memory by 0x%s to 0x%s.\n",
436 wine_dbgstr_longlong(amount),
437 wine_dbgstr_longlong(adapter->vram_bytes_used));
438 return adapter->vram_bytes_used;
441 static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
443 HeapFree(GetProcessHeap(), 0, adapter->gl_info.formats);
444 HeapFree(GetProcessHeap(), 0, adapter->cfgs);
447 ULONG CDECL wined3d_incref(struct wined3d *wined3d)
449 ULONG refcount = InterlockedIncrement(&wined3d->ref);
451 TRACE("%p increasing refcount to %u.\n", wined3d, refcount);
453 return refcount;
456 ULONG CDECL wined3d_decref(struct wined3d *wined3d)
458 ULONG refcount = InterlockedDecrement(&wined3d->ref);
460 TRACE("%p decreasing refcount to %u.\n", wined3d, refcount);
462 if (!refcount)
464 unsigned int i;
466 for (i = 0; i < wined3d->adapter_count; ++i)
468 wined3d_adapter_cleanup(&wined3d->adapters[i]);
470 HeapFree(GetProcessHeap(), 0, wined3d);
473 return refcount;
476 /* Context activation is done by the caller. */
477 static BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
479 GLuint prog;
480 BOOL ret = FALSE;
481 static const char testcode[] =
482 "!!ARBvp1.0\n"
483 "PARAM C[66] = { program.env[0..65] };\n"
484 "ADDRESS A0;"
485 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
486 "ARL A0.x, zero.x;\n"
487 "MOV result.position, C[A0.x + 65];\n"
488 "END\n";
490 while (gl_info->gl_ops.gl.p_glGetError());
491 GL_EXTCALL(glGenProgramsARB(1, &prog));
492 if(!prog) {
493 ERR("Failed to create an ARB offset limit test program\n");
495 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
496 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
497 strlen(testcode), testcode));
498 if (gl_info->gl_ops.gl.p_glGetError())
500 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
501 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
502 ret = TRUE;
503 } else TRACE("OpenGL implementation allows offsets > 63\n");
505 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
506 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
507 checkGLcall("ARB vp offset limit test cleanup");
509 return ret;
512 static BOOL match_amd_r300_to_500(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
513 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
514 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
516 if (card_vendor != HW_VENDOR_AMD) return FALSE;
517 if (device == CARD_AMD_RADEON_9500) return TRUE;
518 if (device == CARD_AMD_RADEON_X700) return TRUE;
519 if (device == CARD_AMD_RADEON_X1600) return TRUE;
520 return FALSE;
523 static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
524 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
525 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
527 if (card_vendor == HW_VENDOR_NVIDIA)
529 if (device == CARD_NVIDIA_GEFORCEFX_5200 ||
530 device == CARD_NVIDIA_GEFORCEFX_5600 ||
531 device == CARD_NVIDIA_GEFORCEFX_5800)
533 return TRUE;
536 return FALSE;
539 static BOOL match_apple(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
540 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
541 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
543 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
544 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
545 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
547 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
548 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
549 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
550 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
551 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
552 * the chance that other implementations support them is rather small since Win32 QuickTime uses
553 * DirectDraw, not OpenGL.
555 * This test has been moved into wined3d_guess_gl_vendor()
557 return gl_vendor == GL_VENDOR_APPLE;
560 /* Context activation is done by the caller. */
561 static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
563 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
564 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
565 * all the texture. This function detects this bug by its symptom and disables PBOs
566 * if the test fails.
568 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
569 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
570 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
571 * read back is compared to the original. If they are equal PBOs are assumed to work,
572 * otherwise the PBO extension is disabled. */
573 GLuint texture, pbo;
574 static const unsigned int pattern[] =
576 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
577 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
578 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
579 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
581 unsigned int check[sizeof(pattern) / sizeof(pattern[0])];
583 /* No PBO -> No point in testing them. */
584 if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
586 while (gl_info->gl_ops.gl.p_glGetError());
587 gl_info->gl_ops.gl.p_glGenTextures(1, &texture);
588 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, texture);
590 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
591 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);
592 checkGLcall("Specifying the PBO test texture");
594 GL_EXTCALL(glGenBuffers(1, &pbo));
595 GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo));
596 GL_EXTCALL(glBufferData(GL_PIXEL_UNPACK_BUFFER, sizeof(pattern), pattern, GL_STREAM_DRAW));
597 checkGLcall("Specifying the PBO test pbo");
599 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);
600 checkGLcall("Loading the PBO test texture");
602 GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
604 gl_info->gl_ops.gl.p_glFinish(); /* just to be sure */
606 memset(check, 0, sizeof(check));
607 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
608 checkGLcall("Reading back the PBO test texture");
610 gl_info->gl_ops.gl.p_glDeleteTextures(1, &texture);
611 GL_EXTCALL(glDeleteBuffers(1, &pbo));
612 checkGLcall("PBO test cleanup");
614 if (memcmp(check, pattern, sizeof(check)))
616 WARN_(d3d_perf)("PBO test failed, read back data doesn't match original.\n"
617 "Disabling PBOs. This may result in slower performance.\n");
618 gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] = FALSE;
620 else
622 TRACE("PBO test successful.\n");
626 static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
627 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
628 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
630 return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE);
633 static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
634 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
635 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
637 if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
638 if (card_vendor != HW_VENDOR_AMD) return FALSE;
639 if (device == CARD_AMD_RADEON_X1600) return FALSE;
640 return TRUE;
643 static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
644 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
645 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
647 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
648 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
649 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
650 * varyings and we subtract one in dx9 shaders it's not going to hurt us because the dx9 limit is
651 * hardcoded
653 * dx10 cards usually have 64 varyings */
654 return gl_info->limits.glsl_varyings > 44;
657 static BOOL match_not_dx10_capable(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
658 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
659 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
661 return !match_dx10_capable(gl_info, ctx, gl_renderer, gl_vendor, card_vendor, device);
664 /* A GL context is provided by the caller */
665 static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
666 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
667 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
669 GLenum error;
670 DWORD data[16];
672 if (!gl_info->supported[EXT_SECONDARY_COLOR])
673 return FALSE;
675 while (gl_info->gl_ops.gl.p_glGetError());
676 GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
677 error = gl_info->gl_ops.gl.p_glGetError();
679 if (error == GL_NO_ERROR)
681 TRACE("GL Implementation accepts 4 component specular color pointers\n");
682 return TRUE;
684 else
686 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
687 debug_glerror(error));
688 return FALSE;
692 /* A GL context is provided by the caller */
693 static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
694 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
695 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
697 GLuint prog;
698 BOOL ret = FALSE;
699 GLint pos;
700 static const char testcode[] =
701 "!!ARBvp1.0\n"
702 "OPTION NV_vertex_program2;\n"
703 "MOV result.clip[0], 0.0;\n"
704 "MOV result.position, 0.0;\n"
705 "END\n";
707 if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE;
709 while (gl_info->gl_ops.gl.p_glGetError());
711 GL_EXTCALL(glGenProgramsARB(1, &prog));
712 if(!prog)
714 ERR("Failed to create the NVvp clip test program\n");
715 return FALSE;
717 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
718 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
719 strlen(testcode), testcode));
720 gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
721 if(pos != -1)
723 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
724 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
725 ret = TRUE;
726 while (gl_info->gl_ops.gl.p_glGetError());
728 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
730 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
731 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
732 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
734 return ret;
737 /* Context activation is done by the caller. */
738 static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
739 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
740 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
742 char data[4 * 4 * 4];
743 GLuint tex, fbo;
744 GLenum status;
746 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE;
748 memset(data, 0xcc, sizeof(data));
750 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
751 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
752 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
753 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
754 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);
755 checkGLcall("glTexImage2D");
757 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
758 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
759 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
760 checkGLcall("glFramebufferTexture2D");
762 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
763 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
764 checkGLcall("glCheckFramebufferStatus");
766 memset(data, 0x11, sizeof(data));
767 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);
768 checkGLcall("glTexSubImage2D");
770 gl_info->gl_ops.gl.p_glClearColor(0.996f, 0.729f, 0.745f, 0.792f);
771 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
772 checkGLcall("glClear");
774 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
775 checkGLcall("glGetTexImage");
777 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
778 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
779 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
780 checkGLcall("glBindTexture");
782 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
783 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
784 checkGLcall("glDeleteTextures");
786 return *(DWORD *)data == 0x11111111;
789 /* Context activation is done by the caller. */
790 static BOOL match_broken_rgba16(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
791 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
792 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
794 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
795 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
796 GLuint tex;
797 GLint size;
799 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
800 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
801 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL);
802 checkGLcall("glTexImage2D");
804 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &size);
805 checkGLcall("glGetTexLevelParameteriv");
806 TRACE("Real color depth is %d\n", size);
808 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
809 checkGLcall("glBindTexture");
810 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
811 checkGLcall("glDeleteTextures");
813 return size < 16;
816 static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
817 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
818 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
820 return gl_vendor == GL_VENDOR_FGLRX;
823 static BOOL match_r200(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
824 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
825 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
827 if (card_vendor != HW_VENDOR_AMD) return FALSE;
828 if (device == CARD_AMD_RADEON_8500) return TRUE;
829 return FALSE;
832 static BOOL match_broken_arb_fog(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
833 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
834 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
836 DWORD data[4];
837 GLuint tex, fbo;
838 GLenum status;
839 float color[4] = {0.0f, 1.0f, 0.0f, 0.0f};
840 GLuint prog;
841 GLint err_pos;
842 static const char program_code[] =
843 "!!ARBfp1.0\n"
844 "OPTION ARB_fog_linear;\n"
845 "MOV result.color, {1.0, 0.0, 0.0, 0.0};\n"
846 "END\n";
848 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
849 return FALSE;
850 if (!gl_info->supported[ARB_FRAGMENT_PROGRAM])
851 return FALSE;
853 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
854 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
855 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
856 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
857 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);
858 checkGLcall("glTexImage2D");
860 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
861 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
862 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
863 checkGLcall("glFramebufferTexture2D");
865 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
866 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
867 checkGLcall("glCheckFramebufferStatus");
869 gl_info->gl_ops.gl.p_glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
870 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
871 checkGLcall("glClear");
872 gl_info->gl_ops.gl.p_glViewport(0, 0, 4, 1);
873 checkGLcall("glViewport");
875 gl_info->gl_ops.gl.p_glEnable(GL_FOG);
876 gl_info->gl_ops.gl.p_glFogf(GL_FOG_START, 0.5f);
877 gl_info->gl_ops.gl.p_glFogf(GL_FOG_END, 0.5f);
878 gl_info->gl_ops.gl.p_glFogi(GL_FOG_MODE, GL_LINEAR);
879 gl_info->gl_ops.gl.p_glHint(GL_FOG_HINT, GL_NICEST);
880 gl_info->gl_ops.gl.p_glFogfv(GL_FOG_COLOR, color);
881 checkGLcall("fog setup");
883 GL_EXTCALL(glGenProgramsARB(1, &prog));
884 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog));
885 GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
886 strlen(program_code), program_code));
887 gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_PROGRAM_ARB);
888 checkGLcall("Test fragment program setup");
890 gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &err_pos);
891 if (err_pos != -1)
893 const char *error_str;
894 error_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB);
895 FIXME("Fog test program error at position %d: %s\n\n", err_pos, debugstr_a(error_str));
898 gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP);
899 gl_info->gl_ops.gl.p_glVertex3f(-1.0f, -1.0f, 0.0f);
900 gl_info->gl_ops.gl.p_glVertex3f( 1.0f, -1.0f, 1.0f);
901 gl_info->gl_ops.gl.p_glVertex3f(-1.0f, 1.0f, 0.0f);
902 gl_info->gl_ops.gl.p_glVertex3f( 1.0f, 1.0f, 1.0f);
903 gl_info->gl_ops.gl.p_glEnd();
904 checkGLcall("ARBfp fog test draw");
906 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
907 checkGLcall("glGetTexImage");
908 data[0] &= 0x00ffffff;
909 data[1] &= 0x00ffffff;
910 data[2] &= 0x00ffffff;
911 data[3] &= 0x00ffffff;
913 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
914 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
916 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
917 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
918 gl_info->gl_ops.gl.p_glDisable(GL_FOG);
919 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0));
920 gl_info->gl_ops.gl.p_glDisable(GL_FRAGMENT_PROGRAM_ARB);
921 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
922 checkGLcall("ARBfp fog test teardown");
924 TRACE("Fog test data: %08x %08x %08x %08x\n", data[0], data[1], data[2], data[3]);
925 return data[0] != 0x00ff0000 || data[3] != 0x0000ff00;
928 static BOOL match_broken_viewport_subpixel_bits(const struct wined3d_gl_info *gl_info,
929 struct wined3d_caps_gl_ctx *ctx, const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
930 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
932 if (!gl_info->supported[ARB_VIEWPORT_ARRAY])
933 return FALSE;
934 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
935 return FALSE;
936 return !wined3d_caps_gl_ctx_test_viewport_subpixel_bits(ctx);
939 static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
941 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
942 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
943 * allow 48 different offsets or other helper immediate values. */
944 TRACE("Reserving 12 GLSL constants for compiler private use.\n");
945 gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 12);
948 static void quirk_amd_dx9(struct wined3d_gl_info *gl_info)
950 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
951 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
952 * If real NP2 textures are used, the driver falls back to software. We could just remove the
953 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconvenient
954 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
955 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
956 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
958 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
959 * has this extension promoted to core. The extension loading code sets this extension supported
960 * due to that, so this code works on fglrx as well. */
961 if(gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
963 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
964 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
965 gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] = TRUE;
969 static void quirk_no_np2(struct wined3d_gl_info *gl_info)
971 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
972 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
973 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
974 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
975 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
976 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
978 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
979 * triggering the software fallback. There is not much we can do here apart from disabling the
980 * software-emulated extension and re-enable ARB_tex_rect (which was previously disabled
981 * in wined3d_adapter_init_gl_caps).
982 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
983 * post-processing effects in the game "Max Payne 2").
984 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
985 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
986 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
987 gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE;
990 static void quirk_texcoord_w(struct wined3d_gl_info *gl_info)
992 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
993 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
994 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
995 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
996 * according to the spec.
998 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
999 * makes the shader slower and eats instruction slots which should be available to the d3d app.
1001 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
1002 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
1003 * this workaround is activated on cards that do not need it, it won't break things, just affect
1004 * performance negatively. */
1005 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
1006 gl_info->quirks |= WINED3D_QUIRK_SET_TEXCOORD_W;
1009 static void quirk_clip_varying(struct wined3d_gl_info *gl_info)
1011 gl_info->quirks |= WINED3D_QUIRK_GLSL_CLIP_VARYING;
1014 static void quirk_allows_specular_alpha(struct wined3d_gl_info *gl_info)
1016 gl_info->quirks |= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA;
1019 static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info)
1021 gl_info->quirks |= WINED3D_QUIRK_NV_CLIP_BROKEN;
1024 static void quirk_fbo_tex_update(struct wined3d_gl_info *gl_info)
1026 gl_info->quirks |= WINED3D_QUIRK_FBO_TEX_UPDATE;
1029 static void quirk_broken_rgba16(struct wined3d_gl_info *gl_info)
1031 gl_info->quirks |= WINED3D_QUIRK_BROKEN_RGBA16;
1034 static void quirk_infolog_spam(struct wined3d_gl_info *gl_info)
1036 gl_info->quirks |= WINED3D_QUIRK_INFO_LOG_SPAM;
1039 static void quirk_limited_tex_filtering(struct wined3d_gl_info *gl_info)
1041 /* Nvidia GeForce 6xxx and 7xxx support accelerated VTF only on a few
1042 selected texture formats. They are apparently the only DX9 class GPUs
1043 supporting VTF.
1044 Also, DX9-era GPUs are somewhat limited with float textures
1045 filtering and blending. */
1046 gl_info->quirks |= WINED3D_QUIRK_LIMITED_TEX_FILTERING;
1049 static void quirk_r200_constants(struct wined3d_gl_info *gl_info)
1051 /* The Mesa r200 driver (and there is no other driver for this GPU Wine would run on)
1052 * loads some fog parameters (start, end, exponent, but not the color) into the
1053 * program.
1055 * Apparently the fog hardware is only able to handle linear fog with a range of 0.0;1.0,
1056 * and it is the responsibility of the vertex pipeline to handle non-linear fog and
1057 * linear fog with start and end other than 0.0 and 1.0. */
1058 TRACE("Reserving 1 ARB constant for compiler private use.\n");
1059 gl_info->reserved_arb_constants = max(gl_info->reserved_arb_constants, 1);
1062 static void quirk_broken_arb_fog(struct wined3d_gl_info *gl_info)
1064 gl_info->quirks |= WINED3D_QUIRK_BROKEN_ARB_FOG;
1067 static void quirk_broken_viewport_subpixel_bits(struct wined3d_gl_info *gl_info)
1069 if (gl_info->supported[ARB_CLIP_CONTROL])
1071 TRACE("Disabling ARB_clip_control.\n");
1072 gl_info->supported[ARB_CLIP_CONTROL] = FALSE;
1076 struct driver_quirk
1078 BOOL (*match)(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
1079 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
1080 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device);
1081 void (*apply)(struct wined3d_gl_info *gl_info);
1082 const char *description;
1085 static const struct driver_quirk quirk_table[] =
1088 match_amd_r300_to_500,
1089 quirk_amd_dx9,
1090 "AMD normalized texrect quirk"
1093 match_apple,
1094 quirk_apple_glsl_constants,
1095 "Apple GLSL uniform override"
1098 match_geforce5,
1099 quirk_no_np2,
1100 "Geforce 5 NP2 disable"
1103 match_apple_intel,
1104 quirk_texcoord_w,
1105 "Init texcoord .w for Apple Intel GPU driver"
1108 match_apple_nonr500ati,
1109 quirk_texcoord_w,
1110 "Init texcoord .w for Apple ATI >= r600 GPU driver"
1113 match_dx10_capable,
1114 quirk_clip_varying,
1115 "Reserved varying for gl_ClipPos"
1118 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
1119 * GL implementations accept it. The Mac GL is the only implementation known to
1120 * reject it.
1122 * If we can pass 4 component specular colors, do it, because (a) we don't have
1123 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
1124 * passes specular alpha to the pixel shader if any is used. Otherwise the
1125 * specular alpha is used to pass the fog coordinate, which we pass to opengl
1126 * via GL_EXT_fog_coord.
1128 match_allows_spec_alpha,
1129 quirk_allows_specular_alpha,
1130 "Allow specular alpha quirk"
1133 match_broken_nv_clip,
1134 quirk_disable_nvvp_clip,
1135 "Apple NV_vertex_program clip bug quirk"
1138 match_fbo_tex_update,
1139 quirk_fbo_tex_update,
1140 "FBO rebind for attachment updates"
1143 match_broken_rgba16,
1144 quirk_broken_rgba16,
1145 "True RGBA16 is not available"
1148 match_fglrx,
1149 quirk_infolog_spam,
1150 "Not printing GLSL infolog"
1153 match_not_dx10_capable,
1154 quirk_limited_tex_filtering,
1155 "Texture filtering, blending and VTF support is limited"
1158 match_r200,
1159 quirk_r200_constants,
1160 "r200 vertex shader constants"
1163 match_broken_arb_fog,
1164 quirk_broken_arb_fog,
1165 "ARBfp fogstart == fogend workaround"
1168 match_broken_viewport_subpixel_bits,
1169 quirk_broken_viewport_subpixel_bits,
1170 "Nvidia viewport subpixel bits bug"
1174 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
1175 * reporting a driver version is moot because we are not the Windows driver, and we have different
1176 * bugs, features, etc.
1178 * The driver version has the form "x.y.z.w".
1180 * "x" is the Windows version the driver is meant for:
1181 * 4 -> 95/98/NT4
1182 * 5 -> 2000
1183 * 6 -> 2000/XP
1184 * 7 -> Vista
1185 * 8 -> Win 7
1187 * "y" is the maximum Direct3D version the driver supports.
1188 * y -> d3d version mapping:
1189 * 11 -> d3d6
1190 * 12 -> d3d7
1191 * 13 -> d3d8
1192 * 14 -> d3d9
1193 * 15 -> d3d10
1194 * 16 -> d3d10.1
1195 * 17 -> d3d11
1197 * "z" is the subversion number.
1199 * "w" is the vendor specific driver build number.
1202 struct driver_version_information
1204 enum wined3d_display_driver driver;
1205 enum wined3d_driver_model driver_model;
1206 const char *driver_name; /* name of Windows driver */
1207 WORD version; /* version word ('y'), contained in low word of DriverVersion.HighPart */
1208 WORD subversion; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
1209 WORD build; /* build number ('w'), contained in low word of DriverVersion.LowPart */
1212 /* The driver version table contains driver information for different devices on several OS versions. */
1213 static const struct driver_version_information driver_version_table[] =
1215 /* AMD
1216 * - Radeon HD2x00 (R600) and up supported by current drivers.
1217 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
1218 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
1219 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
1220 {DRIVER_AMD_RAGE_128PRO, DRIVER_MODEL_NT5X, "ati2dvaa.dll", 13, 3279, 0},
1221 {DRIVER_AMD_R100, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6614},
1222 {DRIVER_AMD_R300, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6764},
1223 {DRIVER_AMD_R600, DRIVER_MODEL_NT5X, "ati2dvag.dll", 17, 10, 1280},
1224 {DRIVER_AMD_R300, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
1225 {DRIVER_AMD_R600, DRIVER_MODEL_NT6X, "atiumdag.dll", 17, 10, 1280},
1226 {DRIVER_AMD_RX, DRIVER_MODEL_NT6X, "aticfx32.dll", 17, 10, 1474},
1228 /* Intel
1229 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
1230 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
1231 * igxprd32.dll but the GMA800 driver was never updated. */
1232 {DRIVER_INTEL_GMA800, DRIVER_MODEL_NT5X, "ialmrnt5.dll", 14, 10, 3889},
1233 {DRIVER_INTEL_GMA900, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4764},
1234 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4926},
1235 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 5218},
1236 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT6X, "igdumd32.dll", 14, 10, 1504},
1237 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT6X, "igdumd32.dll", 15, 10, 1666},
1238 {DRIVER_INTEL_HD4000, DRIVER_MODEL_NT6X, "igdumdim32.dll", 19, 15, 4352},
1240 /* Nvidia
1241 * - Geforce8 and newer is supported by the current 340.52 driver on XP-Win8
1242 * - Geforce6 and 7 support is up to 307.83 on XP-Win8
1243 * - GeforceFX support is up to 173.x on <= XP
1244 * - Geforce2MX/3/4 up to 96.x on <= XP
1245 * - TNT/Geforce1/2 up to 71.x on <= XP
1246 * All version numbers used below are from the Linux nvidia drivers. */
1247 {DRIVER_NVIDIA_TNT, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 7186},
1248 {DRIVER_NVIDIA_GEFORCE2MX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 9371},
1249 {DRIVER_NVIDIA_GEFORCEFX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 11, 7516},
1250 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT5X, "nv4_disp.dll", 18, 13, 783},
1251 {DRIVER_NVIDIA_GEFORCE8, DRIVER_MODEL_NT5X, "nv4_disp.dll", 18, 13, 4052},
1252 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT6X, "nvd3dum.dll", 18, 13, 783},
1253 {DRIVER_NVIDIA_GEFORCE8, DRIVER_MODEL_NT6X, "nvd3dum.dll", 18, 13, 4052},
1255 /* VMware */
1256 {DRIVER_VMWARE, DRIVER_MODEL_NT5X, "vm3dum.dll", 14, 1, 1134},
1259 struct gpu_description
1261 WORD vendor; /* reported PCI card vendor ID */
1262 WORD card; /* reported PCI card device ID */
1263 const char *description; /* Description of the card e.g. NVIDIA RIVA TNT */
1264 enum wined3d_display_driver driver;
1265 unsigned int vidmem;
1268 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1269 * found on a board containing a specific GPU. */
1270 static const struct gpu_description gpu_description_table[] =
1272 /* Nvidia cards */
1273 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_128, "NVIDIA RIVA 128", DRIVER_NVIDIA_TNT, 4 },
1274 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT, 16 },
1275 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT, 32 },
1276 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT, 32 },
1277 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT, 32 },
1278 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX,32 },
1279 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX,64 },
1280 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX,64 },
1281 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX,64, },
1282 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX, 64 },
1283 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX, 128 },
1284 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX, 256 },
1285 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6, 64 },
1286 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6, 128 },
1287 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6, 128 },
1288 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6, 256 },
1289 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6, 256 },
1290 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1291 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1292 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8200, "NVIDIA GeForce 8200", DRIVER_NVIDIA_GEFORCE8, 512 },
1293 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE8, 128 },
1294 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8400GS, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE8, 128 },
1295 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8500GT, "NVIDIA GeForce 8500 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
1296 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
1297 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE8, 512 },
1298 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE8, 320 },
1299 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTX, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE8, 768 },
1300 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE8, 256 },
1301 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9300, "NVIDIA GeForce 9300", DRIVER_NVIDIA_GEFORCE8, 256 },
1302 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400M, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE8, 256 },
1303 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
1304 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
1305 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE8, 512 },
1306 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9700MGT, "NVIDIA GeForce 9700M GT", DRIVER_NVIDIA_GEFORCE8, 512 },
1307 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE8, 512 },
1308 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_210, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE8, 512 },
1309 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT220, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE8, 512 },
1310 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE8, 512 },
1311 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS250, "NVIDIA GeForce GTS 250", DRIVER_NVIDIA_GEFORCE8, 1024},
1312 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE8, 1024},
1313 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE8, 896 },
1314 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE8, 1024},
1315 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_315M, "NVIDIA GeForce 315M", DRIVER_NVIDIA_GEFORCE8, 512 },
1316 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_320M, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE8, 256},
1317 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT320M, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE8, 1024},
1318 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT325M, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE8, 1024},
1319 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT330, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE8, 1024},
1320 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS350M, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE8, 1024},
1321 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_410M, "NVIDIA GeForce 410M", DRIVER_NVIDIA_GEFORCE8, 512},
1322 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT420, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE8, 2048},
1323 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT425M, "NVIDIA GeForce GT 425M", DRIVER_NVIDIA_GEFORCE8, 1024},
1324 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT430, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE8, 1024},
1325 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT440, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE8, 1024},
1326 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS450, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE8, 1024},
1327 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE8, 768 },
1328 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460M, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_GEFORCE8, 1536},
1329 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX465, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE8, 1024},
1330 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX470, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE8, 1280},
1331 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX480, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE8, 1536},
1332 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT520, "NVIDIA GeForce GT 520", DRIVER_NVIDIA_GEFORCE8, 1024},
1333 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT525M, "NVIDIA GeForce GT 525M", DRIVER_NVIDIA_GEFORCE8, 1024},
1334 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT540M, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_GEFORCE8, 1024},
1335 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX550, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
1336 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT555M, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE8, 1024},
1337 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560TI, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
1338 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE8, 1024},
1339 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX570, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE8, 1280},
1340 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX580, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE8, 1536},
1341 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT610, "NVIDIA GeForce GT 610", DRIVER_NVIDIA_GEFORCE8, 1024},
1342 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630, "NVIDIA GeForce GT 630", DRIVER_NVIDIA_GEFORCE8, 1024},
1343 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630M, "NVIDIA GeForce GT 630M", DRIVER_NVIDIA_GEFORCE8, 1024},
1344 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT640M, "NVIDIA GeForce GT 640M", DRIVER_NVIDIA_GEFORCE8, 1024},
1345 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT650M, "NVIDIA GeForce GT 650M", DRIVER_NVIDIA_GEFORCE8, 2048},
1346 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650, "NVIDIA GeForce GTX 650", DRIVER_NVIDIA_GEFORCE8, 1024},
1347 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650TI, "NVIDIA GeForce GTX 650 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
1348 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660, "NVIDIA GeForce GTX 660", DRIVER_NVIDIA_GEFORCE8, 2048},
1349 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660M, "NVIDIA GeForce GTX 660M", DRIVER_NVIDIA_GEFORCE8, 2048},
1350 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660TI, "NVIDIA GeForce GTX 660 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
1351 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_GEFORCE8, 2048},
1352 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670MX, "NVIDIA GeForce GTX 670MX", DRIVER_NVIDIA_GEFORCE8, 3072},
1353 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX675MX, "NVIDIA GeForce GTX 675MX", DRIVER_NVIDIA_GEFORCE8, 4096},
1354 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX680, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_GEFORCE8, 2048},
1355 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX690, "NVIDIA GeForce GTX 690", DRIVER_NVIDIA_GEFORCE8, 2048},
1356 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT730, "NVIDIA GeForce GT 730", DRIVER_NVIDIA_GEFORCE8, 2048},
1357 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT730M, "NVIDIA GeForce GT 730M", DRIVER_NVIDIA_GEFORCE8, 1024},
1358 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT740M, "NVIDIA GeForce GT 740M", DRIVER_NVIDIA_GEFORCE8, 2048},
1359 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT750M, "NVIDIA GeForce GT 750M", DRIVER_NVIDIA_GEFORCE8, 1024},
1360 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX750, "NVIDIA GeForce GTX 750", DRIVER_NVIDIA_GEFORCE8, 1024},
1361 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX750TI, "NVIDIA GeForce GTX 750 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
1362 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX760, "NVIDIA GeForce GTX 760", DRIVER_NVIDIA_GEFORCE8, 2048},
1363 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX760TI, "NVIDIA GeForce GTX 760 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
1364 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX765M, "NVIDIA GeForce GTX 765M", DRIVER_NVIDIA_GEFORCE8, 2048},
1365 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770M, "NVIDIA GeForce GTX 770M", DRIVER_NVIDIA_GEFORCE8, 3072},
1366 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770, "NVIDIA GeForce GTX 770", DRIVER_NVIDIA_GEFORCE8, 2048},
1367 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780, "NVIDIA GeForce GTX 780", DRIVER_NVIDIA_GEFORCE8, 3072},
1368 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780TI, "NVIDIA GeForce GTX 780 Ti", DRIVER_NVIDIA_GEFORCE8, 3072},
1369 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITAN, "NVIDIA GeForce GTX TITAN", DRIVER_NVIDIA_GEFORCE8, 6144},
1370 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANB, "NVIDIA GeForce GTX TITAN Black", DRIVER_NVIDIA_GEFORCE8, 6144},
1371 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANX, "NVIDIA GeForce GTX TITAN X", DRIVER_NVIDIA_GEFORCE8, 12288},
1372 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANZ, "NVIDIA GeForce GTX TITAN Z", DRIVER_NVIDIA_GEFORCE8, 12288},
1373 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_820M, "NVIDIA GeForce 820M", DRIVER_NVIDIA_GEFORCE8, 2048},
1374 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_830M, "NVIDIA GeForce 830M", DRIVER_NVIDIA_GEFORCE8, 2048},
1375 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_840M, "NVIDIA GeForce 840M", DRIVER_NVIDIA_GEFORCE8, 2048},
1376 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_845M, "NVIDIA GeForce 845M", DRIVER_NVIDIA_GEFORCE8, 2048},
1377 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX850M, "NVIDIA GeForce GTX 850M", DRIVER_NVIDIA_GEFORCE8, 2048},
1378 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX860M, "NVIDIA GeForce GTX 860M", DRIVER_NVIDIA_GEFORCE8, 2048},
1379 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX870M, "NVIDIA GeForce GTX 870M", DRIVER_NVIDIA_GEFORCE8, 3072},
1380 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX880M, "NVIDIA GeForce GTX 880M", DRIVER_NVIDIA_GEFORCE8, 4096},
1381 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_940M, "NVIDIA GeForce 940M", DRIVER_NVIDIA_GEFORCE8, 4096},
1382 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX950, "NVIDIA GeForce GTX 950", DRIVER_NVIDIA_GEFORCE8, 2048},
1383 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX950M, "NVIDIA GeForce GTX 950M", DRIVER_NVIDIA_GEFORCE8, 4096},
1384 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX960, "NVIDIA GeForce GTX 960", DRIVER_NVIDIA_GEFORCE8, 4096},
1385 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX960M, "NVIDIA GeForce GTX 960M", DRIVER_NVIDIA_GEFORCE8, 2048},
1386 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX970, "NVIDIA GeForce GTX 970", DRIVER_NVIDIA_GEFORCE8, 4096},
1387 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX970M, "NVIDIA GeForce GTX 970M", DRIVER_NVIDIA_GEFORCE8, 3072},
1388 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX980, "NVIDIA GeForce GTX 980", DRIVER_NVIDIA_GEFORCE8, 4096},
1389 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX980TI, "NVIDIA GeForce GTX 980 Ti", DRIVER_NVIDIA_GEFORCE8, 6144},
1390 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1050, "NVIDIA GeForce GTX 1050", DRIVER_NVIDIA_GEFORCE8, 2048},
1391 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1060, "NVIDIA GeForce GTX 1060", DRIVER_NVIDIA_GEFORCE8, 6144},
1392 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1070, "NVIDIA GeForce GTX 1070", DRIVER_NVIDIA_GEFORCE8, 8192},
1393 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1080, "NVIDIA GeForce GTX 1080", DRIVER_NVIDIA_GEFORCE8, 8192},
1394 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1080TI, "NVIDIA GeForce GTX 1080 Ti", DRIVER_NVIDIA_GEFORCE8, 11264},
1395 {HW_VENDOR_NVIDIA, CARD_NVIDIA_TITANX_PASCAL, "NVIDIA TITAN X (Pascal)", DRIVER_NVIDIA_GEFORCE8, 12288},
1397 /* AMD cards */
1398 {HW_VENDOR_AMD, CARD_AMD_RAGE_128PRO, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO, 16 },
1399 {HW_VENDOR_AMD, CARD_AMD_RADEON_7200, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100, 32 },
1400 {HW_VENDOR_AMD, CARD_AMD_RADEON_8500, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100, 64 },
1401 {HW_VENDOR_AMD, CARD_AMD_RADEON_9500, "ATI Radeon 9500", DRIVER_AMD_R300, 64 },
1402 {HW_VENDOR_AMD, CARD_AMD_RADEON_XPRESS_200M, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300, 64 },
1403 {HW_VENDOR_AMD, CARD_AMD_RADEON_X700, "ATI Radeon X700 SE", DRIVER_AMD_R300, 128 },
1404 {HW_VENDOR_AMD, CARD_AMD_RADEON_X1600, "ATI Radeon X1600 Series", DRIVER_AMD_R300, 128 },
1405 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2350, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600, 256 },
1406 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2600, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600, 256 },
1407 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2900, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600, 512 },
1408 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3200, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600, 128 },
1409 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3850, "ATI Radeon HD 3850 AGP", DRIVER_AMD_R600, 512 },
1410 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4200M, "ATI Mobility Radeon HD 4200", DRIVER_AMD_R600, 256 },
1411 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4350, "ATI Radeon HD 4350", DRIVER_AMD_R600, 256 },
1412 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4600, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600, 512 },
1413 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4700, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600, 512 },
1414 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4800, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600, 512 },
1415 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5400, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600, 512 },
1416 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5600, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600, 512 },
1417 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5700, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600, 512 },
1418 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5800, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600, 1024},
1419 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5900, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600, 1024},
1420 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6300, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600, 1024},
1421 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6400, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600, 1024},
1422 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6410D, "AMD Radeon HD 6410D", DRIVER_AMD_R600, 1024},
1423 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6480G, "AMD Radeon HD 6480G", DRIVER_AMD_R600, 512 },
1424 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6550D, "AMD Radeon HD 6550D", DRIVER_AMD_R600, 1024},
1425 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600, 1024},
1426 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600M, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600, 512 },
1427 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6700, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600, 1024},
1428 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6800, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600, 1024},
1429 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6900, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600, 2048},
1430 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7660D, "AMD Radeon HD 7660D", DRIVER_AMD_R600, 2048},
1431 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7700, "AMD Radeon HD 7700 Series", DRIVER_AMD_R600, 1024},
1432 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7800, "AMD Radeon HD 7800 Series", DRIVER_AMD_R600, 2048},
1433 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7900, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600, 2048},
1434 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8600M, "AMD Radeon HD 8600M Series", DRIVER_AMD_R600, 1024},
1435 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8670, "AMD Radeon HD 8670", DRIVER_AMD_R600, 2048},
1436 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8770, "AMD Radeon HD 8770", DRIVER_AMD_R600, 2048},
1437 {HW_VENDOR_AMD, CARD_AMD_RADEON_R3, "AMD Radeon HD 8400 / R3 Series", DRIVER_AMD_R600, 2048},
1438 {HW_VENDOR_AMD, CARD_AMD_RADEON_R7, "AMD Radeon(TM) R7 Graphics", DRIVER_AMD_R600, 2048},
1439 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_285, "AMD Radeon R9 285", DRIVER_AMD_RX, 2048},
1440 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_290, "AMD Radeon R9 290", DRIVER_AMD_RX, 4096},
1441 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_FURY, "AMD Radeon (TM) R9 Fury Series", DRIVER_AMD_RX, 4096},
1442 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_460, "Radeon(TM) RX 460 Graphics", DRIVER_AMD_RX, 4096},
1443 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_480, "Radeon (TM) RX 480 Graphics", DRIVER_AMD_RX, 4096},
1445 /* VMware */
1446 {HW_VENDOR_VMWARE, CARD_VMWARE_SVGA3D, "VMware SVGA 3D (Microsoft Corporation - WDDM)", DRIVER_VMWARE, 1024},
1448 /* Intel cards */
1449 {HW_VENDOR_INTEL, CARD_INTEL_830M, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1450 {HW_VENDOR_INTEL, CARD_INTEL_855GM, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1451 {HW_VENDOR_INTEL, CARD_INTEL_845G, "Intel(R) 845G", DRIVER_INTEL_GMA800, 32 },
1452 {HW_VENDOR_INTEL, CARD_INTEL_865G, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1453 {HW_VENDOR_INTEL, CARD_INTEL_915G, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
1454 {HW_VENDOR_INTEL, CARD_INTEL_E7221G, "Intel(R) E7221G", DRIVER_INTEL_GMA900, 64 },
1455 {HW_VENDOR_INTEL, CARD_INTEL_915GM, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
1456 {HW_VENDOR_INTEL, CARD_INTEL_945G, "Intel(R) 945G", DRIVER_INTEL_GMA950, 64 },
1457 {HW_VENDOR_INTEL, CARD_INTEL_945GM, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950, 64 },
1458 {HW_VENDOR_INTEL, CARD_INTEL_945GME, "Intel(R) 945GME", DRIVER_INTEL_GMA950, 64 },
1459 {HW_VENDOR_INTEL, CARD_INTEL_Q35, "Intel(R) Q35", DRIVER_INTEL_GMA950, 64 },
1460 {HW_VENDOR_INTEL, CARD_INTEL_G33, "Intel(R) G33", DRIVER_INTEL_GMA950, 64 },
1461 {HW_VENDOR_INTEL, CARD_INTEL_Q33, "Intel(R) Q33", DRIVER_INTEL_GMA950, 64 },
1462 {HW_VENDOR_INTEL, CARD_INTEL_PNVG, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
1463 {HW_VENDOR_INTEL, CARD_INTEL_PNVM, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
1464 {HW_VENDOR_INTEL, CARD_INTEL_965Q, "Intel(R) 965Q", DRIVER_INTEL_GMA3000, 128},
1465 {HW_VENDOR_INTEL, CARD_INTEL_965G, "Intel(R) 965G", DRIVER_INTEL_GMA3000, 128},
1466 {HW_VENDOR_INTEL, CARD_INTEL_946GZ, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000, 128},
1467 {HW_VENDOR_INTEL, CARD_INTEL_965GM, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000, 128},
1468 {HW_VENDOR_INTEL, CARD_INTEL_965GME, "Intel(R) 965GME", DRIVER_INTEL_GMA3000, 128},
1469 {HW_VENDOR_INTEL, CARD_INTEL_GM45, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000, 512},
1470 {HW_VENDOR_INTEL, CARD_INTEL_IGD, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000, 512},
1471 {HW_VENDOR_INTEL, CARD_INTEL_G45, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000, 512},
1472 {HW_VENDOR_INTEL, CARD_INTEL_Q45, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000, 512},
1473 {HW_VENDOR_INTEL, CARD_INTEL_G41, "Intel(R) G41", DRIVER_INTEL_GMA3000, 512},
1474 {HW_VENDOR_INTEL, CARD_INTEL_B43, "Intel(R) B43", DRIVER_INTEL_GMA3000, 512},
1475 {HW_VENDOR_INTEL, CARD_INTEL_ILKD, "Intel(R) HD Graphics", DRIVER_INTEL_GMA3000, 1536},
1476 {HW_VENDOR_INTEL, CARD_INTEL_ILKM, "Intel(R) HD Graphics", DRIVER_INTEL_GMA3000, 1536},
1477 {HW_VENDOR_INTEL, CARD_INTEL_SNBD, "Intel(R) HD Graphics 3000", DRIVER_INTEL_GMA3000, 1536},
1478 {HW_VENDOR_INTEL, CARD_INTEL_SNBM, "Intel(R) HD Graphics 3000", DRIVER_INTEL_GMA3000, 1536},
1479 {HW_VENDOR_INTEL, CARD_INTEL_SNBS, "Intel(R) HD Graphics Family", DRIVER_INTEL_GMA3000, 1536},
1480 {HW_VENDOR_INTEL, CARD_INTEL_IVBD, "Intel(R) HD Graphics 4000", DRIVER_INTEL_HD4000, 1536},
1481 {HW_VENDOR_INTEL, CARD_INTEL_IVBM, "Intel(R) HD Graphics 4000", DRIVER_INTEL_HD4000, 1536},
1482 {HW_VENDOR_INTEL, CARD_INTEL_IVBS, "Intel(R) HD Graphics Family", DRIVER_INTEL_HD4000, 1536},
1483 {HW_VENDOR_INTEL, CARD_INTEL_HWD, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536},
1484 {HW_VENDOR_INTEL, CARD_INTEL_HWM, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536},
1485 {HW_VENDOR_INTEL, CARD_INTEL_I5100_1, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
1486 {HW_VENDOR_INTEL, CARD_INTEL_I5100_2, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
1487 {HW_VENDOR_INTEL, CARD_INTEL_I5100_3, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
1488 {HW_VENDOR_INTEL, CARD_INTEL_I5100_4, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
1489 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_1, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1490 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_2, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1491 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_3, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1492 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_4, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1493 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_5, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1494 {HW_VENDOR_INTEL, CARD_INTEL_HD5300, "Intel(R) HD Graphics 5300", DRIVER_INTEL_HD4000, 2048},
1495 {HW_VENDOR_INTEL, CARD_INTEL_HD5500, "Intel(R) HD Graphics 5500", DRIVER_INTEL_HD4000, 2048},
1496 {HW_VENDOR_INTEL, CARD_INTEL_HD5600, "Intel(R) HD Graphics 5600", DRIVER_INTEL_HD4000, 2048},
1497 {HW_VENDOR_INTEL, CARD_INTEL_HD6000, "Intel(R) HD Graphics 6000", DRIVER_INTEL_HD4000, 2048},
1498 {HW_VENDOR_INTEL, CARD_INTEL_I6100, "Intel(R) Iris(TM) Graphics 6100", DRIVER_INTEL_HD4000, 2048},
1499 {HW_VENDOR_INTEL, CARD_INTEL_IP6200, "Intel(R) Iris(TM) Pro Graphics 6200", DRIVER_INTEL_HD4000, 2048},
1500 {HW_VENDOR_INTEL, CARD_INTEL_IPP6300, "Intel(R) Iris(TM) Pro Graphics P6300", DRIVER_INTEL_HD4000, 2048},
1501 {HW_VENDOR_INTEL, CARD_INTEL_HD510_1, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
1502 {HW_VENDOR_INTEL, CARD_INTEL_HD510_2, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
1503 {HW_VENDOR_INTEL, CARD_INTEL_HD510_3, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
1504 {HW_VENDOR_INTEL, CARD_INTEL_HD515, "Intel(R) HD Graphics 515", DRIVER_INTEL_HD4000, 2048},
1505 {HW_VENDOR_INTEL, CARD_INTEL_HD520_1, "Intel(R) HD Graphics 520", DRIVER_INTEL_HD4000, 2048},
1506 {HW_VENDOR_INTEL, CARD_INTEL_HD520_2, "Intel(R) HD Graphics 520", DRIVER_INTEL_HD4000, 2048},
1507 {HW_VENDOR_INTEL, CARD_INTEL_HD530_1, "Intel(R) HD Graphics 530", DRIVER_INTEL_HD4000, 2048},
1508 {HW_VENDOR_INTEL, CARD_INTEL_HD530_2, "Intel(R) HD Graphics 530", DRIVER_INTEL_HD4000, 2048},
1509 {HW_VENDOR_INTEL, CARD_INTEL_HDP530, "Intel(R) HD Graphics P530", DRIVER_INTEL_HD4000, 2048},
1510 {HW_VENDOR_INTEL, CARD_INTEL_I540, "Intel(R) Iris(TM) Graphics 540", DRIVER_INTEL_HD4000, 2048},
1511 {HW_VENDOR_INTEL, CARD_INTEL_I550, "Intel(R) Iris(TM) Graphics 550", DRIVER_INTEL_HD4000, 2048},
1512 {HW_VENDOR_INTEL, CARD_INTEL_I555, "Intel(R) Iris(TM) Graphics 555", DRIVER_INTEL_HD4000, 2048},
1513 {HW_VENDOR_INTEL, CARD_INTEL_IP555, "Intel(R) Iris(TM) Graphics P555", DRIVER_INTEL_HD4000, 2048},
1514 {HW_VENDOR_INTEL, CARD_INTEL_IP580_1, "Intel(R) Iris(TM) Pro Graphics 580", DRIVER_INTEL_HD4000, 2048},
1515 {HW_VENDOR_INTEL, CARD_INTEL_IP580_2, "Intel(R) Iris(TM) Pro Graphics 580", DRIVER_INTEL_HD4000, 2048},
1516 {HW_VENDOR_INTEL, CARD_INTEL_IPP580_1, "Intel(R) Iris(TM) Pro Graphics P580", DRIVER_INTEL_HD4000, 2048},
1517 {HW_VENDOR_INTEL, CARD_INTEL_IPP580_2, "Intel(R) Iris(TM) Pro Graphics P580", DRIVER_INTEL_HD4000, 2048},
1520 static const struct driver_version_information *get_driver_version_info(enum wined3d_display_driver driver,
1521 enum wined3d_driver_model driver_model)
1523 unsigned int i;
1525 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver, driver_model);
1526 for (i = 0; i < (sizeof(driver_version_table) / sizeof(driver_version_table[0])); i++)
1528 const struct driver_version_information *entry = &driver_version_table[i];
1530 if (entry->driver == driver && (driver_model == DRIVER_MODEL_GENERIC
1531 || entry->driver_model == driver_model))
1533 TRACE("Found driver \"%s\", version %u, subversion %u, build %u.\n",
1534 entry->driver_name, entry->version, entry->subversion, entry->build);
1535 return entry;
1538 return NULL;
1541 static const struct gpu_description *get_gpu_description(enum wined3d_pci_vendor vendor,
1542 enum wined3d_pci_device device)
1544 unsigned int i;
1546 for (i = 0; i < (sizeof(gpu_description_table) / sizeof(*gpu_description_table)); ++i)
1548 if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].card)
1549 return &gpu_description_table[i];
1552 return NULL;
1555 static const struct gpu_description *query_gpu_description(const struct wined3d_gl_info *gl_info, UINT64 *vram_bytes)
1557 enum wined3d_pci_vendor vendor = PCI_VENDOR_NONE;
1558 enum wined3d_pci_device device = PCI_DEVICE_NONE;
1559 const struct gpu_description *gpu_description;
1560 static unsigned int once;
1562 if (gl_info->supported[WGL_WINE_QUERY_RENDERER])
1564 GLuint value;
1566 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_VENDOR_ID_WINE, &value)))
1567 vendor = value;
1568 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_DEVICE_ID_WINE, &value)))
1569 device = value;
1570 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_VIDEO_MEMORY_WINE, &value)))
1571 *vram_bytes = (UINT64)value * 1024 * 1024;
1572 TRACE("Card reports vendor PCI ID 0x%04x, device PCI ID 0x%04x, 0x%s bytes of video memory.\n",
1573 vendor, device, wine_dbgstr_longlong(*vram_bytes));
1576 if (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
1578 vendor = wined3d_settings.pci_vendor_id;
1579 TRACE("Overriding vendor PCI ID with 0x%04x.\n", vendor);
1582 if (wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
1584 device = wined3d_settings.pci_device_id;
1585 TRACE("Overriding device PCI ID with 0x%04x.\n", device);
1588 if (wined3d_settings.emulated_textureram)
1590 *vram_bytes = wined3d_settings.emulated_textureram;
1591 TRACE("Overriding amount of video memory with 0x%s bytes.\n",
1592 wine_dbgstr_longlong(*vram_bytes));
1595 if (!(gpu_description = get_gpu_description(vendor, device))
1596 && (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE
1597 || wined3d_settings.pci_device_id != PCI_DEVICE_NONE) && !once++)
1598 ERR_(winediag)("Invalid GPU override %04x:%04x specified, ignoring.\n", vendor, device);
1600 return gpu_description;
1603 static void init_driver_info(struct wined3d_driver_info *driver_info,
1604 const struct gpu_description *gpu_desc, UINT64 vram_bytes)
1606 OSVERSIONINFOW os_version;
1607 WORD driver_os_version;
1608 enum wined3d_display_driver driver;
1609 enum wined3d_driver_model driver_model;
1610 const struct driver_version_information *version_info;
1612 memset(&os_version, 0, sizeof(os_version));
1613 os_version.dwOSVersionInfoSize = sizeof(os_version);
1614 if (!GetVersionExW(&os_version))
1616 ERR("Failed to get OS version, reporting 2000/XP.\n");
1617 driver_os_version = 6;
1618 driver_model = DRIVER_MODEL_NT5X;
1620 else
1622 TRACE("OS version %u.%u.\n", os_version.dwMajorVersion, os_version.dwMinorVersion);
1623 switch (os_version.dwMajorVersion)
1625 case 4:
1626 /* If needed we could distinguish between 9x and NT4, but this code won't make
1627 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1629 driver_os_version = 4;
1630 driver_model = DRIVER_MODEL_WIN9X;
1631 break;
1633 case 5:
1634 driver_os_version = 6;
1635 driver_model = DRIVER_MODEL_NT5X;
1636 break;
1638 case 6:
1639 if (os_version.dwMinorVersion == 0)
1641 driver_os_version = 7;
1642 driver_model = DRIVER_MODEL_NT6X;
1644 else if (os_version.dwMinorVersion == 1)
1646 driver_os_version = 8;
1647 driver_model = DRIVER_MODEL_NT6X;
1649 else
1651 if (os_version.dwMinorVersion > 2)
1653 FIXME("Unhandled OS version %u.%u, reporting Win 8.\n",
1654 os_version.dwMajorVersion, os_version.dwMinorVersion);
1656 driver_os_version = 9;
1657 driver_model = DRIVER_MODEL_NT6X;
1659 break;
1661 case 10:
1662 driver_os_version = 10;
1663 driver_model = DRIVER_MODEL_NT6X;
1664 break;
1666 default:
1667 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1668 os_version.dwMajorVersion, os_version.dwMinorVersion);
1669 driver_os_version = 6;
1670 driver_model = DRIVER_MODEL_NT5X;
1671 break;
1675 driver_info->vendor = gpu_desc->vendor;
1676 driver_info->device = gpu_desc->card;
1677 driver_info->description = gpu_desc->description;
1678 driver_info->vram_bytes = vram_bytes ? vram_bytes : (UINT64)gpu_desc->vidmem * 1024 * 1024;
1679 driver = gpu_desc->driver;
1682 * Diablo 2 crashes when the amount of video memory is greater than 0x7fffffff.
1683 * In order to avoid this application bug we limit the amount of video memory
1684 * to LONG_MAX for older Windows versions.
1686 if (driver_model < DRIVER_MODEL_NT6X && driver_info->vram_bytes > LONG_MAX)
1688 TRACE("Limiting amount of video memory to %#lx bytes for OS version older than Vista.\n", LONG_MAX);
1689 driver_info->vram_bytes = LONG_MAX;
1692 /* Try to obtain driver version information for the current Windows version. This fails in
1693 * some cases:
1694 * - the gpu is not available on the currently selected OS version:
1695 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1696 * version information for the current Windows version is returned instead of faked info.
1697 * We do the same and assume the default Windows version to emulate is WinXP.
1699 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1700 * For now return the XP driver info. Perhaps later on we should return VESA.
1702 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1703 * This could be an indication that our database is not up to date, so this should be fixed.
1705 if ((version_info = get_driver_version_info(driver, driver_model))
1706 || (version_info = get_driver_version_info(driver, DRIVER_MODEL_GENERIC)))
1708 driver_info->name = version_info->driver_name;
1709 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version);
1710 driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
1712 else
1714 ERR("No driver version info found for device %04x:%04x, driver model %#x.\n",
1715 driver_info->vendor, driver_info->device, driver_model);
1716 driver_info->name = "Display";
1717 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, 15);
1718 driver_info->version_low = MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1721 TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1722 driver_info->version_high, driver_info->version_low);
1725 /* Context activation is done by the caller. */
1726 static void fixup_extensions(struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
1727 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
1728 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
1730 unsigned int i;
1732 for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i)
1734 if (!quirk_table[i].match(gl_info, ctx, gl_renderer, gl_vendor, card_vendor, device)) continue;
1735 TRACE("Applying driver quirk \"%s\".\n", quirk_table[i].description);
1736 quirk_table[i].apply(gl_info);
1739 /* Find out if PBOs work as they are supposed to. */
1740 test_pbo_functionality(gl_info);
1743 static DWORD wined3d_parse_gl_version(const char *gl_version)
1745 const char *ptr = gl_version;
1746 int major, minor;
1748 major = atoi(ptr);
1749 if (major <= 0)
1750 ERR("Invalid OpenGL major version %d.\n", major);
1752 while (isdigit(*ptr)) ++ptr;
1753 if (*ptr++ != '.')
1754 ERR("Invalid OpenGL version string %s.\n", debugstr_a(gl_version));
1756 minor = atoi(ptr);
1758 TRACE("Found OpenGL version %d.%d.\n", major, minor);
1760 return MAKEDWORD_VERSION(major, minor);
1763 static enum wined3d_gl_vendor wined3d_guess_gl_vendor(const struct wined3d_gl_info *gl_info,
1764 const char *gl_vendor_string, const char *gl_renderer, const char *gl_version)
1766 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1767 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1768 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1770 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1771 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1772 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1773 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1774 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1775 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1776 * DirectDraw, not OpenGL. */
1777 if (gl_info->supported[APPLE_FENCE] && gl_info->supported[APPLE_YCBCR_422])
1778 return GL_VENDOR_APPLE;
1780 if (strstr(gl_vendor_string, "NVIDIA"))
1781 return GL_VENDOR_NVIDIA;
1783 if (strstr(gl_vendor_string, "ATI"))
1784 return GL_VENDOR_FGLRX;
1786 if (strstr(gl_vendor_string, "Mesa")
1787 || strstr(gl_vendor_string, "X.Org")
1788 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1789 || strstr(gl_vendor_string, "DRI R300 Project")
1790 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1791 || strstr(gl_vendor_string, "VMware, Inc.")
1792 || strstr(gl_vendor_string, "Intel")
1793 || strstr(gl_renderer, "Mesa")
1794 || strstr(gl_renderer, "Gallium")
1795 || strstr(gl_renderer, "Intel")
1796 || strstr(gl_version, "Mesa"))
1797 return GL_VENDOR_MESA;
1799 FIXME("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1800 debugstr_a(gl_vendor_string));
1802 return GL_VENDOR_UNKNOWN;
1805 static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer)
1807 if (strstr(gl_vendor_string, "NVIDIA")
1808 || strstr(gl_vendor_string, "Nouveau")
1809 || strstr(gl_vendor_string, "nouveau"))
1810 return HW_VENDOR_NVIDIA;
1812 if (strstr(gl_vendor_string, "ATI")
1813 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1814 || strstr(gl_vendor_string, "X.Org R300 Project")
1815 || strstr(gl_renderer, "AMD")
1816 || strstr(gl_renderer, "R100")
1817 || strstr(gl_renderer, "R200")
1818 || strstr(gl_renderer, "R300")
1819 || strstr(gl_renderer, "R600")
1820 || strstr(gl_renderer, "R700"))
1821 return HW_VENDOR_AMD;
1823 if (strstr(gl_vendor_string, "Intel(R)")
1824 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1825 || strstr(gl_renderer, "Intel")
1826 || strstr(gl_renderer, "i915")
1827 || strstr(gl_vendor_string, "Intel Inc."))
1828 return HW_VENDOR_INTEL;
1830 if (strstr(gl_renderer, "SVGA3D"))
1831 return HW_VENDOR_VMWARE;
1833 if (strstr(gl_vendor_string, "Mesa")
1834 || strstr(gl_vendor_string, "Brian Paul")
1835 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1836 || strstr(gl_vendor_string, "VMware, Inc."))
1837 return HW_VENDOR_SOFTWARE;
1839 FIXME("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string));
1841 return HW_VENDOR_NVIDIA;
1844 static enum wined3d_d3d_level d3d_level_from_caps(const struct shader_caps *shader_caps, const struct fragment_caps *fragment_caps, DWORD glsl_version)
1846 if (shader_caps->vs_version >= 5)
1847 return WINED3D_D3D_LEVEL_11;
1848 if (shader_caps->vs_version == 4)
1849 return WINED3D_D3D_LEVEL_10;
1850 if (shader_caps->vs_version == 3)
1852 /* wined3d with default settings at the moment doesn't expose SM4+ on
1853 * Mesa drivers. */
1854 if (glsl_version >= MAKEDWORD_VERSION(4, 30))
1855 return WINED3D_D3D_LEVEL_11;
1856 if (glsl_version >= MAKEDWORD_VERSION(1, 30))
1857 return WINED3D_D3D_LEVEL_10;
1858 return WINED3D_D3D_LEVEL_9_SM3;
1860 if (shader_caps->vs_version == 2)
1861 return WINED3D_D3D_LEVEL_9_SM2;
1862 if (shader_caps->vs_version == 1)
1863 return WINED3D_D3D_LEVEL_8;
1865 if (fragment_caps->TextureOpCaps & WINED3DTEXOPCAPS_DOTPRODUCT3)
1866 return WINED3D_D3D_LEVEL_7;
1867 if (fragment_caps->MaxSimultaneousTextures > 1)
1868 return WINED3D_D3D_LEVEL_6;
1870 return WINED3D_D3D_LEVEL_5;
1873 static const struct wined3d_renderer_table
1875 const char *renderer;
1876 enum wined3d_pci_device id;
1878 cards_nvidia_binary[] =
1880 /* Direct 3D 11 */
1881 {"TITAN X (Pascal)", CARD_NVIDIA_TITANX_PASCAL}, /* GeForce 1000 - highend */
1882 {"GTX 1080 Ti", CARD_NVIDIA_GEFORCE_GTX1080TI}, /* GeForce 1000 - highend */
1883 {"GTX 1080", CARD_NVIDIA_GEFORCE_GTX1080}, /* GeForce 1000 - highend */
1884 {"GTX 1070", CARD_NVIDIA_GEFORCE_GTX1070}, /* GeForce 1000 - highend */
1885 {"GTX 1060", CARD_NVIDIA_GEFORCE_GTX1060}, /* GeForce 1000 - midend high */
1886 {"GTX 1050", CARD_NVIDIA_GEFORCE_GTX1050}, /* GeForce 1000 - midend */
1887 {"GTX 980 Ti", CARD_NVIDIA_GEFORCE_GTX980TI}, /* GeForce 900 - highend */
1888 {"GTX 980", CARD_NVIDIA_GEFORCE_GTX980}, /* GeForce 900 - highend */
1889 {"GTX 970M", CARD_NVIDIA_GEFORCE_GTX970M}, /* GeForce 900 - highend mobile*/
1890 {"GTX 970", CARD_NVIDIA_GEFORCE_GTX970}, /* GeForce 900 - highend */
1891 {"GTX TITAN X", CARD_NVIDIA_GEFORCE_GTXTITANX}, /* Geforce 900 - highend */
1892 {"GTX 960M", CARD_NVIDIA_GEFORCE_GTX960M}, /* GeForce 900 - midend high mobile */
1893 {"GTX 960", CARD_NVIDIA_GEFORCE_GTX960}, /* GeForce 900 - midend high */
1894 {"GTX 950M", CARD_NVIDIA_GEFORCE_GTX950M}, /* GeForce 900 - midend mobile */
1895 {"GTX 950", CARD_NVIDIA_GEFORCE_GTX950}, /* GeForce 900 - midend */
1896 {"GeForce 940M", CARD_NVIDIA_GEFORCE_940M}, /* GeForce 900 - midend mobile */
1897 {"GTX 880M", CARD_NVIDIA_GEFORCE_GTX880M}, /* GeForce 800 - mobile */
1898 {"GTX 870M", CARD_NVIDIA_GEFORCE_GTX870M}, /* GeForce 800 - mobile */
1899 {"GTX 860M", CARD_NVIDIA_GEFORCE_GTX860M}, /* GeForce 800 - mobile */
1900 {"GTX 850M", CARD_NVIDIA_GEFORCE_GTX850M}, /* GeForce 800 - mobile */
1901 {"GeForce 845M", CARD_NVIDIA_GEFORCE_845M}, /* GeForce 800 - mobile */
1902 {"GeForce 840M", CARD_NVIDIA_GEFORCE_840M}, /* GeForce 800 - mobile */
1903 {"GeForce 830M", CARD_NVIDIA_GEFORCE_830M}, /* GeForce 800 - mobile */
1904 {"GeForce 820M", CARD_NVIDIA_GEFORCE_820M}, /* GeForce 800 - mobile */
1905 {"GTX 780 Ti", CARD_NVIDIA_GEFORCE_GTX780TI}, /* Geforce 700 - highend */
1906 {"GTX TITAN Black", CARD_NVIDIA_GEFORCE_GTXTITANB}, /* Geforce 700 - highend */
1907 {"GTX TITAN Z", CARD_NVIDIA_GEFORCE_GTXTITANZ}, /* Geforce 700 - highend */
1908 {"GTX TITAN", CARD_NVIDIA_GEFORCE_GTXTITAN}, /* Geforce 700 - highend */
1909 {"GTX 780", CARD_NVIDIA_GEFORCE_GTX780}, /* Geforce 700 - highend */
1910 {"GTX 770M", CARD_NVIDIA_GEFORCE_GTX770M}, /* Geforce 700 - midend high mobile */
1911 {"GTX 770", CARD_NVIDIA_GEFORCE_GTX770}, /* Geforce 700 - highend */
1912 {"GTX 765M", CARD_NVIDIA_GEFORCE_GTX765M}, /* Geforce 700 - midend high mobile */
1913 {"GTX 760 Ti", CARD_NVIDIA_GEFORCE_GTX760TI}, /* Geforce 700 - midend high */
1914 {"GTX 760", CARD_NVIDIA_GEFORCE_GTX760}, /* Geforce 700 - midend high */
1915 {"GTX 750 Ti", CARD_NVIDIA_GEFORCE_GTX750TI}, /* Geforce 700 - midend */
1916 {"GTX 750", CARD_NVIDIA_GEFORCE_GTX750}, /* Geforce 700 - midend */
1917 {"GT 750M", CARD_NVIDIA_GEFORCE_GT750M}, /* Geforce 700 - midend mobile */
1918 {"GT 740M", CARD_NVIDIA_GEFORCE_GT740M}, /* Geforce 700 - midend mobile */
1919 {"GT 730M", CARD_NVIDIA_GEFORCE_GT730M}, /* Geforce 700 - midend mobile */
1920 {"GT 730", CARD_NVIDIA_GEFORCE_GT730}, /* Geforce 700 - lowend */
1921 {"GTX 690", CARD_NVIDIA_GEFORCE_GTX690}, /* Geforce 600 - highend */
1922 {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680}, /* Geforce 600 - highend */
1923 {"GTX 675MX", CARD_NVIDIA_GEFORCE_GTX675MX}, /* Geforce 600 - highend */
1924 {"GTX 670MX", CARD_NVIDIA_GEFORCE_GTX670MX}, /* Geforce 600 - highend */
1925 {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670}, /* Geforce 600 - midend high */
1926 {"GTX 660 Ti", CARD_NVIDIA_GEFORCE_GTX660TI}, /* Geforce 600 - midend high */
1927 {"GTX 660M", CARD_NVIDIA_GEFORCE_GTX660M}, /* Geforce 600 - midend high mobile */
1928 {"GTX 660", CARD_NVIDIA_GEFORCE_GTX660}, /* Geforce 600 - midend high */
1929 {"GTX 650 Ti", CARD_NVIDIA_GEFORCE_GTX650TI}, /* Geforce 600 - lowend */
1930 {"GTX 650", CARD_NVIDIA_GEFORCE_GTX650}, /* Geforce 600 - lowend */
1931 {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M}, /* Geforce 600 - midend mobile */
1932 {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M}, /* Geforce 600 - midend mobile */
1933 {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M}, /* Geforce 600 - midend mobile */
1934 {"GT 630", CARD_NVIDIA_GEFORCE_GT630}, /* Geforce 600 - lowend */
1935 {"GT 610", CARD_NVIDIA_GEFORCE_GT610}, /* Geforce 600 - lowend */
1936 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */
1937 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */
1938 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI}, /* Geforce 500 - midend */
1939 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */
1940 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M}, /* Geforce 500 - midend mobile */
1941 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550}, /* Geforce 500 - midend */
1942 {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M}, /* Geforce 500 - midend mobile */
1943 {"GT 525M", CARD_NVIDIA_GEFORCE_GT525M}, /* Geforce 500 - lowend mobile */
1944 {"GT 520", CARD_NVIDIA_GEFORCE_GT520}, /* Geforce 500 - lowend */
1945 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480}, /* Geforce 400 - highend */
1946 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470}, /* Geforce 400 - midend high */
1947 /* Direct 3D 10 */
1948 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465}, /* Geforce 400 - midend */
1949 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M}, /* Geforce 400 - highend mobile */
1950 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460}, /* Geforce 400 - midend */
1951 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450}, /* Geforce 400 - midend low */
1952 {"GT 440", CARD_NVIDIA_GEFORCE_GT440}, /* Geforce 400 - lowend */
1953 {"GT 430", CARD_NVIDIA_GEFORCE_GT430}, /* Geforce 400 - lowend */
1954 {"GT 425M", CARD_NVIDIA_GEFORCE_GT425M}, /* Geforce 400 - lowend mobile */
1955 {"GT 420", CARD_NVIDIA_GEFORCE_GT420}, /* Geforce 400 - lowend */
1956 {"410M", CARD_NVIDIA_GEFORCE_410M}, /* Geforce 400 - lowend mobile */
1957 {"GT 330", CARD_NVIDIA_GEFORCE_GT330}, /* Geforce 300 - highend */
1958 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1959 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1960 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1961 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1962 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M}, /* Geforce 300 - midend mobile */
1963 {"320M", CARD_NVIDIA_GEFORCE_320M}, /* Geforce 300 - midend mobile */
1964 {"315M", CARD_NVIDIA_GEFORCE_315M}, /* Geforce 300 - midend mobile */
1965 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1966 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1967 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1968 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275}, /* Geforce 200 - midend high */
1969 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260}, /* Geforce 200 - midend */
1970 {"GTS 250", CARD_NVIDIA_GEFORCE_GTS250}, /* Geforce 200 - midend */
1971 {"GT 240", CARD_NVIDIA_GEFORCE_GT240}, /* Geforce 200 - midend */
1972 {"GT 220", CARD_NVIDIA_GEFORCE_GT220}, /* Geforce 200 - lowend */
1973 {"GeForce 310", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1974 {"GeForce 305", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1975 {"GeForce 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1976 {"G 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1977 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1978 {"9800", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1979 {"9700M GT", CARD_NVIDIA_GEFORCE_9700MGT}, /* Geforce 9 - midend */
1980 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1981 {"9600", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1982 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1983 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1984 {"9500", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1985 {"9400M", CARD_NVIDIA_GEFORCE_9400M}, /* Geforce 9 - lowend */
1986 {"9400", CARD_NVIDIA_GEFORCE_9400GT}, /* Geforce 9 - lowend */
1987 {"9300", CARD_NVIDIA_GEFORCE_9300}, /* Geforce 9 - lowend low */
1988 {"9200", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1989 {"9100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1990 {"G 100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1991 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX}, /* Geforce 8 - highend high */
1992 {"8800", CARD_NVIDIA_GEFORCE_8800GTS}, /* Geforce 8 - highend */
1993 {"8600M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
1994 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
1995 {"8700", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
1996 {"8600", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
1997 {"8500", CARD_NVIDIA_GEFORCE_8500GT}, /* Geforce 8 - mid-lowend */
1998 {"8400", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
1999 {"8300", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
2000 {"8200", CARD_NVIDIA_GEFORCE_8200}, /* Geforce 8 - lowend */
2001 {"8100", CARD_NVIDIA_GEFORCE_8200}, /* Geforce 8 - lowend */
2002 /* Direct 3D 9 SM3 */
2003 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
2004 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
2005 {"7950", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
2006 {"7900", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
2007 {"7800", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
2008 {"7700", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
2009 {"7600", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
2010 {"7400", CARD_NVIDIA_GEFORCE_7400}, /* Geforce 7 - lower medium */
2011 {"7300", CARD_NVIDIA_GEFORCE_7300}, /* Geforce 7 - lowend */
2012 {"6800", CARD_NVIDIA_GEFORCE_6800}, /* Geforce 6 - highend */
2013 {"6700", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
2014 {"6610", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
2015 {"6600", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
2016 /* Direct 3D 9 SM2 */
2017 {"Quadro FX", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
2018 {"5950", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
2019 {"5900", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
2020 {"5800", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
2021 {"5750", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
2022 {"5700", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
2023 {"5650", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
2024 {"5600", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
2025 {"5500", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2026 {"5300", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2027 {"5250", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2028 {"5200", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2029 {"5100", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2030 /* Direct 3D 8 */
2031 {"Quadro4", CARD_NVIDIA_GEFORCE4_TI4200},
2032 {"GeForce4 Ti", CARD_NVIDIA_GEFORCE4_TI4200}, /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800 */
2033 /* Direct 3D 7 */
2034 {"GeForce4 MX", CARD_NVIDIA_GEFORCE4_MX}, /* MX420/MX440/MX460/MX4000 */
2035 {"Quadro2 MXR", CARD_NVIDIA_GEFORCE2_MX},
2036 {"GeForce2 MX", CARD_NVIDIA_GEFORCE2_MX}, /* Geforce2 standard/MX100/MX200/MX400 */
2037 {"Quadro2", CARD_NVIDIA_GEFORCE2},
2038 {"GeForce2", CARD_NVIDIA_GEFORCE2}, /* Geforce2 GTS/Pro/Ti/Ultra */
2039 /* Direct 3D 6 */
2040 {"TNT2", CARD_NVIDIA_RIVA_TNT2}, /* Riva TNT2 standard/M64/Pro/Ultra */
2042 /* See http://developer.amd.com/resources/hardware-drivers/ati-catalyst-pc-vendor-id-1002-li/
2044 * Beware: renderer string do not match exact card model,
2045 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
2046 cards_amd_binary[] =
2048 {"RX 480", CARD_AMD_RADEON_RX_480},
2049 {"RX 460", CARD_AMD_RADEON_RX_460},
2050 {"R9 Fury Series", CARD_AMD_RADEON_R9_FURY},
2051 /* Southern Islands */
2052 {"HD 7900", CARD_AMD_RADEON_HD7900},
2053 {"HD 7800", CARD_AMD_RADEON_HD7800},
2054 {"HD 7700", CARD_AMD_RADEON_HD7700},
2055 /* Northern Islands */
2056 {"HD 6970", CARD_AMD_RADEON_HD6900},
2057 {"HD 6900", CARD_AMD_RADEON_HD6900},
2058 {"HD 6800", CARD_AMD_RADEON_HD6800},
2059 {"HD 6770M", CARD_AMD_RADEON_HD6600M},
2060 {"HD 6750M", CARD_AMD_RADEON_HD6600M},
2061 {"HD 6700", CARD_AMD_RADEON_HD6700},
2062 {"HD 6670", CARD_AMD_RADEON_HD6600},
2063 {"HD 6630M", CARD_AMD_RADEON_HD6600M},
2064 {"HD 6600M", CARD_AMD_RADEON_HD6600M},
2065 {"HD 6600", CARD_AMD_RADEON_HD6600},
2066 {"HD 6570", CARD_AMD_RADEON_HD6600},
2067 {"HD 6500M", CARD_AMD_RADEON_HD6600M},
2068 {"HD 6500", CARD_AMD_RADEON_HD6600},
2069 {"HD 6480G", CARD_AMD_RADEON_HD6480G},
2070 {"HD 6400", CARD_AMD_RADEON_HD6400},
2071 {"HD 6300", CARD_AMD_RADEON_HD6300},
2072 {"HD 6200", CARD_AMD_RADEON_HD6300},
2073 /* Evergreen */
2074 {"HD 5870", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS PRO */
2075 {"HD 5850", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS XT */
2076 {"HD 5800", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS HD58xx generic renderer string */
2077 {"HD 5770", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER XT */
2078 {"HD 5750", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER LE */
2079 {"HD 5700", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER HD57xx generic renderer string */
2080 {"HD 5670", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD XT */
2081 {"HD 5570", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
2082 {"HD 5550", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
2083 {"HD 5450", CARD_AMD_RADEON_HD5400}, /* Radeon EG CEDAR PRO */
2084 {"HD 5000", CARD_AMD_RADEON_HD5600}, /* Defaulting to HD 5600 */
2085 /* R700 */
2086 {"HD 4890", CARD_AMD_RADEON_HD4800}, /* Radeon RV790 */
2087 {"HD 4870", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
2088 {"HD 4850", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
2089 {"HD 4830", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
2090 {"HD 4800", CARD_AMD_RADEON_HD4800}, /* Radeon RV7xx HD48xx generic renderer string */
2091 {"HD 4770", CARD_AMD_RADEON_HD4700}, /* Radeon RV740 */
2092 {"HD 4700", CARD_AMD_RADEON_HD4700}, /* Radeon RV7xx HD47xx generic renderer string */
2093 {"HD 4670", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
2094 {"HD 4650", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
2095 {"HD 4600", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
2096 {"HD 4550", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
2097 {"HD 4350", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
2098 /* R600/R700 integrated */
2099 {"HD 4200M", CARD_AMD_RADEON_HD4200M},
2100 {"HD 3300", CARD_AMD_RADEON_HD3200},
2101 {"HD 3200", CARD_AMD_RADEON_HD3200},
2102 {"HD 3100", CARD_AMD_RADEON_HD3200},
2103 /* R600 */
2104 {"HD 3870", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
2105 {"HD 3850", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
2106 {"HD 2900", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
2107 {"HD 3830", CARD_AMD_RADEON_HD2600}, /* China-only midend */
2108 {"HD 3690", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
2109 {"HD 3650", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
2110 {"HD 2600", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
2111 {"HD 3470", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2112 {"HD 3450", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2113 {"HD 3430", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2114 {"HD 3400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2115 {"HD 2400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2116 {"HD 2350", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2117 /* Radeon R5xx */
2118 {"X1950", CARD_AMD_RADEON_X1600},
2119 {"X1900", CARD_AMD_RADEON_X1600},
2120 {"X1800", CARD_AMD_RADEON_X1600},
2121 {"X1650", CARD_AMD_RADEON_X1600},
2122 {"X1600", CARD_AMD_RADEON_X1600},
2123 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
2124 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
2125 {"HD 2300", CARD_AMD_RADEON_X700},
2126 {"X2500", CARD_AMD_RADEON_X700},
2127 {"X2300", CARD_AMD_RADEON_X700},
2128 {"X1550", CARD_AMD_RADEON_X700},
2129 {"X1450", CARD_AMD_RADEON_X700},
2130 {"X1400", CARD_AMD_RADEON_X700},
2131 {"X1300", CARD_AMD_RADEON_X700},
2132 {"X850", CARD_AMD_RADEON_X700},
2133 {"X800", CARD_AMD_RADEON_X700},
2134 {"X700", CARD_AMD_RADEON_X700},
2135 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400 MHz */
2136 {"Radeon Xpress", CARD_AMD_RADEON_XPRESS_200M},
2138 cards_intel[] =
2140 /* Skylake */
2141 {"Iris Pro Graphics P580", CARD_INTEL_IPP580_1},
2142 {"Skylake", CARD_INTEL_HD520_1},
2143 /* Broadwell */
2144 {"Iris Pro P6300", CARD_INTEL_IPP6300},
2145 {"Iris Pro 6200", CARD_INTEL_IP6200},
2146 {"Iris 6100", CARD_INTEL_I6100},
2147 {"Iris(TM) Graphics 6100", CARD_INTEL_I6100}, /* MacOS */
2148 /* Haswell */
2149 {"Iris Pro 5200", CARD_INTEL_IP5200_1},
2150 {"Iris 5100", CARD_INTEL_I5100_1},
2151 {"Haswell Mobile", CARD_INTEL_HWM},
2152 {"Iris OpenGL Engine", CARD_INTEL_HWM}, /* MacOS */
2153 /* Ivybridge */
2154 {"Ivybridge Server", CARD_INTEL_IVBS},
2155 {"Ivybridge Mobile", CARD_INTEL_IVBM},
2156 {"Ivybridge Desktop", CARD_INTEL_IVBD},
2157 {"HD Graphics 4000", CARD_INTEL_IVBD}, /* MacOS */
2158 /* Sandybridge */
2159 {"Sandybridge Server", CARD_INTEL_SNBS},
2160 {"Sandybridge Mobile", CARD_INTEL_SNBM},
2161 {"Sandybridge Desktop", CARD_INTEL_SNBD},
2162 /* Ironlake */
2163 {"Ironlake Mobile", CARD_INTEL_ILKM},
2164 {"Ironlake Desktop", CARD_INTEL_ILKD},
2165 /* G4x */
2166 {"B43", CARD_INTEL_B43},
2167 {"G41", CARD_INTEL_G41},
2168 {"G45", CARD_INTEL_G45},
2169 {"Q45", CARD_INTEL_Q45},
2170 {"Integrated Graphics Device", CARD_INTEL_IGD},
2171 {"GM45", CARD_INTEL_GM45},
2172 /* i965 */
2173 {"965GME", CARD_INTEL_965GME},
2174 {"965GM", CARD_INTEL_965GM},
2175 {"X3100", CARD_INTEL_965GM}, /* MacOS */
2176 {"946GZ", CARD_INTEL_946GZ},
2177 {"965G", CARD_INTEL_965G},
2178 {"965Q", CARD_INTEL_965Q},
2179 /* i945 */
2180 {"Pineview M", CARD_INTEL_PNVM},
2181 {"Pineview G", CARD_INTEL_PNVG},
2182 {"IGD", CARD_INTEL_PNVG},
2183 {"Q33", CARD_INTEL_Q33},
2184 {"G33", CARD_INTEL_G33},
2185 {"Q35", CARD_INTEL_Q35},
2186 {"945GME", CARD_INTEL_945GME},
2187 {"945GM", CARD_INTEL_945GM},
2188 {"GMA 950", CARD_INTEL_945GM}, /* MacOS */
2189 {"945G", CARD_INTEL_945G},
2190 /* i915 */
2191 {"915GM", CARD_INTEL_915GM},
2192 {"E7221G", CARD_INTEL_E7221G},
2193 {"915G", CARD_INTEL_915G},
2194 /* i8xx */
2195 {"865G", CARD_INTEL_865G},
2196 {"845G", CARD_INTEL_845G},
2197 {"855GM", CARD_INTEL_855GM},
2198 {"830M", CARD_INTEL_830M},
2200 /* 20101109 - These are never returned by current Gallium radeon
2201 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
2203 * These are returned but not handled: RC410, RV380. */
2204 cards_amd_mesa[] =
2206 /* Polaris 10/11 */
2207 {"POLARIS10", CARD_AMD_RADEON_RX_480},
2208 {"POLARIS11", CARD_AMD_RADEON_RX_460},
2209 /* Volcanic Islands */
2210 {"FIJI", CARD_AMD_RADEON_R9_FURY},
2211 {"TONGA", CARD_AMD_RADEON_R9_285},
2212 /* Sea Islands */
2213 {"HAWAII", CARD_AMD_RADEON_R9_290},
2214 {"KAVERI", CARD_AMD_RADEON_R7 },
2215 {"KABINI", CARD_AMD_RADEON_R3 },
2216 {"BONAIRE", CARD_AMD_RADEON_HD8770},
2217 /* Southern Islands */
2218 {"OLAND", CARD_AMD_RADEON_HD8670},
2219 {"HAINAN", CARD_AMD_RADEON_HD8600M},
2220 {"TAHITI", CARD_AMD_RADEON_HD7900},
2221 {"PITCAIRN", CARD_AMD_RADEON_HD7800},
2222 {"CAPE VERDE", CARD_AMD_RADEON_HD7700},
2223 /* Northern Islands */
2224 {"ARUBA", CARD_AMD_RADEON_HD7660D},
2225 {"CAYMAN", CARD_AMD_RADEON_HD6900},
2226 {"BARTS", CARD_AMD_RADEON_HD6800},
2227 {"TURKS", CARD_AMD_RADEON_HD6600},
2228 {"SUMO2", CARD_AMD_RADEON_HD6410D}, /* SUMO2 first, because we do a strstr(). */
2229 {"SUMO", CARD_AMD_RADEON_HD6550D},
2230 {"CAICOS", CARD_AMD_RADEON_HD6400},
2231 {"PALM", CARD_AMD_RADEON_HD6300},
2232 /* Evergreen */
2233 {"HEMLOCK", CARD_AMD_RADEON_HD5900},
2234 {"CYPRESS", CARD_AMD_RADEON_HD5800},
2235 {"JUNIPER", CARD_AMD_RADEON_HD5700},
2236 {"REDWOOD", CARD_AMD_RADEON_HD5600},
2237 {"CEDAR", CARD_AMD_RADEON_HD5400},
2238 /* R700 */
2239 {"R700", CARD_AMD_RADEON_HD4800},
2240 {"RV790", CARD_AMD_RADEON_HD4800},
2241 {"RV770", CARD_AMD_RADEON_HD4800},
2242 {"RV740", CARD_AMD_RADEON_HD4700},
2243 {"RV730", CARD_AMD_RADEON_HD4600},
2244 {"RV710", CARD_AMD_RADEON_HD4350},
2245 /* R600/R700 integrated */
2246 {"RS880", CARD_AMD_RADEON_HD4200M},
2247 {"RS780", CARD_AMD_RADEON_HD3200},
2248 /* R600 */
2249 {"R680", CARD_AMD_RADEON_HD2900},
2250 {"R600", CARD_AMD_RADEON_HD2900},
2251 {"RV670", CARD_AMD_RADEON_HD3850},
2252 {"RV635", CARD_AMD_RADEON_HD2600},
2253 {"RV630", CARD_AMD_RADEON_HD2600},
2254 {"RV620", CARD_AMD_RADEON_HD2350},
2255 {"RV610", CARD_AMD_RADEON_HD2350},
2256 /* R500 */
2257 {"R580", CARD_AMD_RADEON_X1600},
2258 {"R520", CARD_AMD_RADEON_X1600},
2259 {"RV570", CARD_AMD_RADEON_X1600},
2260 {"RV560", CARD_AMD_RADEON_X1600},
2261 {"RV535", CARD_AMD_RADEON_X1600},
2262 {"RV530", CARD_AMD_RADEON_X1600},
2263 {"RV516", CARD_AMD_RADEON_X700},
2264 {"RV515", CARD_AMD_RADEON_X700},
2265 /* R400 */
2266 {"R481", CARD_AMD_RADEON_X700},
2267 {"R480", CARD_AMD_RADEON_X700},
2268 {"R430", CARD_AMD_RADEON_X700},
2269 {"R423", CARD_AMD_RADEON_X700},
2270 {"R420", CARD_AMD_RADEON_X700},
2271 {"R410", CARD_AMD_RADEON_X700},
2272 {"RV410", CARD_AMD_RADEON_X700},
2273 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400 MHz */
2274 {"RS740", CARD_AMD_RADEON_XPRESS_200M},
2275 {"RS690", CARD_AMD_RADEON_XPRESS_200M},
2276 {"RS600", CARD_AMD_RADEON_XPRESS_200M},
2277 {"RS485", CARD_AMD_RADEON_XPRESS_200M},
2278 {"RS482", CARD_AMD_RADEON_XPRESS_200M},
2279 {"RS480", CARD_AMD_RADEON_XPRESS_200M},
2280 {"RS400", CARD_AMD_RADEON_XPRESS_200M},
2281 /* R300 */
2282 {"R360", CARD_AMD_RADEON_9500},
2283 {"R350", CARD_AMD_RADEON_9500},
2284 {"R300", CARD_AMD_RADEON_9500},
2285 {"RV370", CARD_AMD_RADEON_9500},
2286 {"RV360", CARD_AMD_RADEON_9500},
2287 {"RV351", CARD_AMD_RADEON_9500},
2288 {"RV350", CARD_AMD_RADEON_9500},
2290 cards_nvidia_mesa[] =
2292 /* Maxwell */
2293 {"NV124", CARD_NVIDIA_GEFORCE_GTX970},
2294 {"NV120", CARD_NVIDIA_GEFORCE_GTX980TI},
2295 {"NV118", CARD_NVIDIA_GEFORCE_840M},
2296 {"NV117", CARD_NVIDIA_GEFORCE_GTX750},
2297 /* Kepler */
2298 {"NV108", CARD_NVIDIA_GEFORCE_GT740M},
2299 {"NVF1", CARD_NVIDIA_GEFORCE_GTX780TI},
2300 {"NVF0", CARD_NVIDIA_GEFORCE_GTX780},
2301 {"NVE6", CARD_NVIDIA_GEFORCE_GTX770M},
2302 {"NVE4", CARD_NVIDIA_GEFORCE_GTX680}, /* 690 / 675MX / 760TI */
2303 /* Fermi */
2304 {"NVD9", CARD_NVIDIA_GEFORCE_GT520},
2305 {"NVD7", CARD_NVIDIA_GEFORCE_820M},
2306 {"NVCF", CARD_NVIDIA_GEFORCE_GTX550},
2307 {"NVCE", CARD_NVIDIA_GEFORCE_GTX560},
2308 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570},
2309 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460},
2310 {"NVC3", CARD_NVIDIA_GEFORCE_GT440},
2311 {"NVC1", CARD_NVIDIA_GEFORCE_GT420},
2312 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480},
2313 /* Tesla */
2314 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M},
2315 {"NVAC", CARD_NVIDIA_GEFORCE_8200},
2316 {"NVAA", CARD_NVIDIA_GEFORCE_8200}, /* 8100 */
2317 {"NVA8", CARD_NVIDIA_GEFORCE_210},
2318 {"NVA5", CARD_NVIDIA_GEFORCE_GT220},
2319 {"NVA3", CARD_NVIDIA_GEFORCE_GT240},
2320 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280},
2321 {"NV98", CARD_NVIDIA_GEFORCE_9200},
2322 {"NV96", CARD_NVIDIA_GEFORCE_9400GT},
2323 {"NV94", CARD_NVIDIA_GEFORCE_9600GT},
2324 {"NV92", CARD_NVIDIA_GEFORCE_9800GT},
2325 {"NV86", CARD_NVIDIA_GEFORCE_8500GT},
2326 {"NV84", CARD_NVIDIA_GEFORCE_8600GT},
2327 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX},
2328 /* Curie */
2329 {"NV68", CARD_NVIDIA_GEFORCE_6200}, /* 7050 */
2330 {"NV67", CARD_NVIDIA_GEFORCE_6200}, /* 7000M */
2331 {"NV63", CARD_NVIDIA_GEFORCE_6200}, /* 7100 */
2332 {"NV4E", CARD_NVIDIA_GEFORCE_6200}, /* 6100 Go / 6150 Go */
2333 {"NV4C", CARD_NVIDIA_GEFORCE_6200}, /* 6150SE */
2334 {"NV4B", CARD_NVIDIA_GEFORCE_7600},
2335 {"NV4A", CARD_NVIDIA_GEFORCE_6200},
2336 {"NV49", CARD_NVIDIA_GEFORCE_7800GT}, /* 7900 */
2337 {"NV47", CARD_NVIDIA_GEFORCE_7800GT},
2338 {"NV46", CARD_NVIDIA_GEFORCE_7400},
2339 {"NV45", CARD_NVIDIA_GEFORCE_6800},
2340 {"NV44", CARD_NVIDIA_GEFORCE_6200},
2341 {"NV43", CARD_NVIDIA_GEFORCE_6600GT},
2342 {"NV42", CARD_NVIDIA_GEFORCE_6800},
2343 {"NV41", CARD_NVIDIA_GEFORCE_6800},
2344 {"NV40", CARD_NVIDIA_GEFORCE_6800},
2345 /* Rankine */
2346 {"NV38", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5950 Ultra */
2347 {"NV36", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5700/5750 */
2348 {"NV35", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5900 */
2349 {"NV34", CARD_NVIDIA_GEFORCEFX_5200},
2350 {"NV31", CARD_NVIDIA_GEFORCEFX_5600},
2351 {"NV30", CARD_NVIDIA_GEFORCEFX_5800},
2352 /* Kelvin */
2353 {"nv28", CARD_NVIDIA_GEFORCE4_TI4200},
2354 {"nv25", CARD_NVIDIA_GEFORCE4_TI4200},
2355 {"nv20", CARD_NVIDIA_GEFORCE3},
2356 /* Celsius */
2357 {"nv1F", CARD_NVIDIA_GEFORCE4_MX}, /* GF4 MX IGP */
2358 {"nv1A", CARD_NVIDIA_GEFORCE2}, /* GF2 IGP */
2359 {"nv18", CARD_NVIDIA_GEFORCE4_MX},
2360 {"nv17", CARD_NVIDIA_GEFORCE4_MX},
2361 {"nv16", CARD_NVIDIA_GEFORCE2},
2362 {"nv15", CARD_NVIDIA_GEFORCE2},
2363 {"nv11", CARD_NVIDIA_GEFORCE2_MX},
2364 {"nv10", CARD_NVIDIA_GEFORCE},
2365 /* Fahrenheit */
2366 {"nv05", CARD_NVIDIA_RIVA_TNT2},
2367 {"nv04", CARD_NVIDIA_RIVA_TNT},
2368 {"nv03", CARD_NVIDIA_RIVA_128},
2370 cards_vmware[] =
2372 {"SVGA3D", CARD_VMWARE_SVGA3D},
2375 static const struct gl_vendor_selection
2377 enum wined3d_gl_vendor gl_vendor;
2378 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
2379 const struct wined3d_renderer_table *cards; /* To be used as cards[], pointer to the first member in an array */
2380 size_t cards_size; /* Number of entries in the array above */
2382 amd_gl_vendor_table[] =
2384 {GL_VENDOR_APPLE, "Apple OSX AMD/ATI binary driver", cards_amd_binary, ARRAY_SIZE(cards_amd_binary)},
2385 {GL_VENDOR_FGLRX, "AMD/ATI binary driver", cards_amd_binary, ARRAY_SIZE(cards_amd_binary)},
2386 {GL_VENDOR_MESA, "Mesa AMD/ATI driver", cards_amd_mesa, ARRAY_SIZE(cards_amd_mesa)},
2388 nvidia_gl_vendor_table[] =
2390 {GL_VENDOR_APPLE, "Apple OSX NVidia binary driver", cards_nvidia_binary, ARRAY_SIZE(cards_nvidia_binary)},
2391 {GL_VENDOR_MESA, "Mesa Nouveau driver", cards_nvidia_mesa, ARRAY_SIZE(cards_nvidia_mesa)},
2392 {GL_VENDOR_NVIDIA, "Nvidia binary driver", cards_nvidia_binary, ARRAY_SIZE(cards_nvidia_binary)},
2394 vmware_gl_vendor_table[] =
2396 {GL_VENDOR_MESA, "VMware driver", cards_vmware, ARRAY_SIZE(cards_vmware)},
2398 intel_gl_vendor_table[] =
2400 {GL_VENDOR_APPLE, "Apple OSX Intel binary driver", cards_intel, ARRAY_SIZE(cards_intel)},
2401 {GL_VENDOR_MESA, "Mesa Intel driver", cards_intel, ARRAY_SIZE(cards_intel)},
2404 static const enum wined3d_pci_device
2405 card_fallback_nvidia[] =
2407 CARD_NVIDIA_RIVA_128, /* D3D5 */
2408 CARD_NVIDIA_RIVA_TNT, /* D3D6 */
2409 CARD_NVIDIA_GEFORCE, /* D3D7 */
2410 CARD_NVIDIA_GEFORCE3, /* D3D8 */
2411 CARD_NVIDIA_GEFORCEFX_5800, /* D3D9_SM2 */
2412 CARD_NVIDIA_GEFORCE_6800, /* D3D9_SM3 */
2413 CARD_NVIDIA_GEFORCE_8800GTX, /* D3D10 */
2414 CARD_NVIDIA_GEFORCE_GTX470, /* D3D11 */
2416 card_fallback_amd[] =
2418 CARD_AMD_RAGE_128PRO, /* D3D5 */
2419 CARD_AMD_RAGE_128PRO, /* D3D6 */
2420 CARD_AMD_RADEON_7200, /* D3D7 */
2421 CARD_AMD_RADEON_8500, /* D3D8 */
2422 CARD_AMD_RADEON_9500, /* D3D9_SM2 */
2423 CARD_AMD_RADEON_X1600, /* D3D9_SM3 */
2424 CARD_AMD_RADEON_HD2900, /* D3D10 */
2425 CARD_AMD_RADEON_HD5600, /* D3D11 */
2427 card_fallback_intel[] =
2429 CARD_INTEL_845G, /* D3D5 */
2430 CARD_INTEL_845G, /* D3D6 */
2431 CARD_INTEL_845G, /* D3D7 */
2432 CARD_INTEL_915G, /* D3D8 */
2433 CARD_INTEL_915G, /* D3D9_SM2 */
2434 CARD_INTEL_945G, /* D3D9_SM3 */
2435 CARD_INTEL_G45, /* D3D10 */
2436 CARD_INTEL_IVBD, /* D3D11 */
2438 C_ASSERT(ARRAY_SIZE(card_fallback_nvidia) == WINED3D_D3D_LEVEL_COUNT);
2439 C_ASSERT(ARRAY_SIZE(card_fallback_amd) == WINED3D_D3D_LEVEL_COUNT);
2440 C_ASSERT(ARRAY_SIZE(card_fallback_intel) == WINED3D_D3D_LEVEL_COUNT);
2442 static enum wined3d_pci_device select_card_handler(const struct gl_vendor_selection *table,
2443 unsigned int table_size, enum wined3d_gl_vendor gl_vendor, const char *gl_renderer)
2445 unsigned int i, j;
2447 for (i = 0; i < table_size; ++i)
2449 if (table[i].gl_vendor != gl_vendor)
2450 continue;
2452 TRACE("Applying card selector \"%s\".\n", table[i].description);
2454 for (j = 0; j < table[i].cards_size; ++j)
2456 if (strstr(gl_renderer, table[i].cards[j].renderer))
2457 return table[i].cards[j].id;
2459 return PCI_DEVICE_NONE;
2461 FIXME("Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n",
2462 gl_vendor, debugstr_a(gl_renderer));
2464 return PCI_DEVICE_NONE;
2467 static const struct
2469 enum wined3d_pci_vendor card_vendor;
2470 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
2471 const struct gl_vendor_selection *gl_vendor_selection;
2472 unsigned int gl_vendor_count;
2473 const enum wined3d_pci_device *card_fallback; /* An array with D3D_LEVEL_COUNT elements */
2475 card_vendor_table[] =
2477 {HW_VENDOR_AMD, "AMD", amd_gl_vendor_table,
2478 sizeof(amd_gl_vendor_table) / sizeof(*amd_gl_vendor_table),
2479 card_fallback_amd},
2480 {HW_VENDOR_NVIDIA, "Nvidia", nvidia_gl_vendor_table,
2481 sizeof(nvidia_gl_vendor_table) / sizeof(*nvidia_gl_vendor_table),
2482 card_fallback_nvidia},
2483 {HW_VENDOR_VMWARE, "VMware", vmware_gl_vendor_table,
2484 sizeof(vmware_gl_vendor_table) / sizeof(*vmware_gl_vendor_table),
2485 card_fallback_amd},
2486 {HW_VENDOR_INTEL, "Intel", intel_gl_vendor_table,
2487 sizeof(intel_gl_vendor_table) / sizeof(*intel_gl_vendor_table),
2488 card_fallback_intel},
2492 static enum wined3d_pci_device wined3d_guess_card(const struct shader_caps *shader_caps, const struct fragment_caps *fragment_caps,
2493 DWORD glsl_version, const char *gl_renderer, enum wined3d_gl_vendor *gl_vendor, enum wined3d_pci_vendor *card_vendor)
2495 /* A Direct3D device object contains the PCI id (vendor + device) of the
2496 * videocard which is used for rendering. Various applications use this
2497 * information to get a rough estimation of the features of the card and
2498 * some might use it for enabling 3d effects only on certain types of
2499 * videocards. In some cases games might even use it to work around bugs
2500 * which happen on certain videocards/driver combinations. The problem is
2501 * that OpenGL only exposes a rendering string containing the name of the
2502 * videocard and not the PCI id.
2504 * Various games depend on the PCI id, so somehow we need to provide one.
2505 * A simple option is to parse the renderer string and translate this to
2506 * the right PCI id. This is a lot of work because there are more than 200
2507 * GPUs just for Nvidia. Various cards share the same renderer string, so
2508 * the amount of code might be 'small' but there are quite a number of
2509 * exceptions which would make this a pain to maintain. Another way would
2510 * be to query the PCI id from the operating system (assuming this is the
2511 * videocard which is used for rendering which is not always the case).
2512 * This would work but it is not very portable. Second it would not work
2513 * well in, let's say, a remote X situation in which the amount of 3d
2514 * features which can be used is limited.
2516 * As said most games only use the PCI id to get an indication of the
2517 * capabilities of the card. It doesn't really matter if the given id is
2518 * the correct one if we return the id of a card with similar 3d features.
2520 * The code below checks the OpenGL capabilities of a videocard and matches
2521 * that to a certain level of Direct3D functionality. Once a card passes
2522 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
2523 * least a GeforceFX. To give a better estimate we do a basic check on the
2524 * renderer string but if that won't pass we return a default card. This
2525 * way is better than maintaining a full card database as even without a
2526 * full database we can return a card with similar features. Second the
2527 * size of the database can be made quite small because when you know what
2528 * type of 3d functionality a card has, you know to which GPU family the
2529 * GPU must belong. Because of this you only have to check a small part of
2530 * the renderer string to distinguish between different models from that
2531 * family.
2533 * The code also selects a default amount of video memory which we will
2534 * use for an estimation of the amount of free texture memory. In case of
2535 * real D3D the amount of texture memory includes video memory and system
2536 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2537 * HyperMemory). We don't know how much system memory can be addressed by
2538 * the system but we can make a reasonable estimation about the amount of
2539 * video memory. If the value is slightly wrong it doesn't matter as we
2540 * didn't include AGP-like memory which makes the amount of addressable
2541 * memory higher and second OpenGL isn't that critical it moves to system
2542 * memory behind our backs if really needed. Note that the amount of video
2543 * memory can be overruled using a registry setting. */
2545 unsigned int i;
2546 enum wined3d_d3d_level d3d_level = d3d_level_from_caps(shader_caps, fragment_caps, glsl_version);
2547 enum wined3d_pci_device device;
2549 for (i = 0; i < (sizeof(card_vendor_table) / sizeof(*card_vendor_table)); ++i)
2551 if (card_vendor_table[i].card_vendor != *card_vendor)
2552 continue;
2554 TRACE("Applying card selector \"%s\".\n", card_vendor_table[i].description);
2555 device = select_card_handler(card_vendor_table[i].gl_vendor_selection,
2556 card_vendor_table[i].gl_vendor_count, *gl_vendor, gl_renderer);
2557 if (device != PCI_DEVICE_NONE)
2558 return device;
2560 TRACE("Unrecognized renderer %s, falling back to default.\n", debugstr_a(gl_renderer));
2561 return card_vendor_table[i].card_fallback[d3d_level];
2564 FIXME("No card selector available for card vendor %04x (using GL_RENDERER %s).\n",
2565 *card_vendor, debugstr_a(gl_renderer));
2567 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. */
2568 *card_vendor = HW_VENDOR_NVIDIA;
2569 return card_fallback_nvidia[d3d_level];
2572 static const struct wined3d_vertex_pipe_ops *select_vertex_implementation(const struct wined3d_gl_info *gl_info,
2573 const struct wined3d_shader_backend_ops *shader_backend_ops)
2575 if (shader_backend_ops == &glsl_shader_backend && gl_info->supported[ARB_VERTEX_SHADER])
2576 return &glsl_vertex_pipe;
2577 return &ffp_vertex_pipe;
2580 static const struct fragment_pipeline *select_fragment_implementation(const struct wined3d_gl_info *gl_info,
2581 const struct wined3d_shader_backend_ops *shader_backend_ops)
2583 if (shader_backend_ops == &glsl_shader_backend && gl_info->supported[ARB_FRAGMENT_SHADER])
2584 return &glsl_fragment_pipe;
2585 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2586 return &arbfp_fragment_pipeline;
2587 if (gl_info->supported[ATI_FRAGMENT_SHADER])
2588 return &atifs_fragment_pipeline;
2589 if (gl_info->supported[NV_REGISTER_COMBINERS] && gl_info->supported[NV_TEXTURE_SHADER2])
2590 return &nvts_fragment_pipeline;
2591 if (gl_info->supported[NV_REGISTER_COMBINERS])
2592 return &nvrc_fragment_pipeline;
2593 return &ffp_fragment_pipeline;
2596 static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info)
2598 BOOL glsl = wined3d_settings.glslRequested && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20);
2600 if (glsl && gl_info->supported[ARB_VERTEX_SHADER] && gl_info->supported[ARB_FRAGMENT_SHADER])
2601 return &glsl_shader_backend;
2602 if (gl_info->supported[ARB_VERTEX_PROGRAM] && gl_info->supported[ARB_FRAGMENT_PROGRAM])
2603 return &arb_program_shader_backend;
2604 if (glsl && (gl_info->supported[ARB_VERTEX_SHADER] || gl_info->supported[ARB_FRAGMENT_SHADER]))
2605 return &glsl_shader_backend;
2606 if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_FRAGMENT_PROGRAM])
2607 return &arb_program_shader_backend;
2608 return &none_shader_backend;
2611 static void parse_extension_string(struct wined3d_gl_info *gl_info, const char *extensions,
2612 const struct wined3d_extension_map *map, UINT entry_count)
2614 while (*extensions)
2616 const char *start;
2617 size_t len;
2618 UINT i;
2620 while (isspace(*extensions))
2621 ++extensions;
2622 start = extensions;
2623 while (!isspace(*extensions) && *extensions)
2624 ++extensions;
2626 len = extensions - start;
2627 if (!len)
2628 continue;
2630 TRACE("- %s.\n", debugstr_an(start, len));
2632 for (i = 0; i < entry_count; ++i)
2634 if (len == strlen(map[i].extension_string)
2635 && !memcmp(start, map[i].extension_string, len))
2637 TRACE(" FOUND: %s support.\n", map[i].extension_string);
2638 gl_info->supported[map[i].extension] = TRUE;
2639 break;
2645 static void enumerate_gl_extensions(struct wined3d_gl_info *gl_info,
2646 const struct wined3d_extension_map *map, unsigned int map_entries_count)
2648 const char *gl_extension_name;
2649 unsigned int i, j;
2650 GLint extensions_count;
2652 gl_info->gl_ops.gl.p_glGetIntegerv(GL_NUM_EXTENSIONS, &extensions_count);
2653 for (i = 0; i < extensions_count; ++i)
2655 gl_extension_name = (const char *)GL_EXTCALL(glGetStringi(GL_EXTENSIONS, i));
2656 TRACE("- %s.\n", debugstr_a(gl_extension_name));
2657 for (j = 0; j < map_entries_count; ++j)
2659 if (!strcmp(gl_extension_name, map[j].extension_string))
2661 TRACE("FOUND: %s support.\n", map[j].extension_string);
2662 gl_info->supported[map[j].extension] = TRUE;
2663 break;
2669 static void load_gl_funcs(struct wined3d_gl_info *gl_info)
2671 #define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
2672 /* GL_APPLE_fence */
2673 USE_GL_FUNC(glDeleteFencesAPPLE)
2674 USE_GL_FUNC(glFinishFenceAPPLE)
2675 USE_GL_FUNC(glFinishObjectAPPLE)
2676 USE_GL_FUNC(glGenFencesAPPLE)
2677 USE_GL_FUNC(glIsFenceAPPLE)
2678 USE_GL_FUNC(glSetFenceAPPLE)
2679 USE_GL_FUNC(glTestFenceAPPLE)
2680 USE_GL_FUNC(glTestObjectAPPLE)
2681 /* GL_APPLE_flush_buffer_range */
2682 USE_GL_FUNC(glBufferParameteriAPPLE)
2683 USE_GL_FUNC(glFlushMappedBufferRangeAPPLE)
2684 /* GL_ARB_blend_func_extended */
2685 USE_GL_FUNC(glBindFragDataLocationIndexed)
2686 USE_GL_FUNC(glGetFragDataIndex)
2687 /* GL_ARB_clear_buffer_object */
2688 USE_GL_FUNC(glClearBufferData)
2689 USE_GL_FUNC(glClearBufferSubData)
2690 /* GL_ARB_clear_texture */
2691 USE_GL_FUNC(glClearTexImage)
2692 USE_GL_FUNC(glClearTexSubImage)
2693 /* GL_ARB_clip_control */
2694 USE_GL_FUNC(glClipControl)
2695 /* GL_ARB_color_buffer_float */
2696 USE_GL_FUNC(glClampColorARB)
2697 /* GL_ARB_compute_shader */
2698 USE_GL_FUNC(glDispatchCompute)
2699 USE_GL_FUNC(glDispatchComputeIndirect)
2700 /* GL_ARB_copy_buffer */
2701 USE_GL_FUNC(glCopyBufferSubData)
2702 /* GL_ARB_debug_output */
2703 USE_GL_FUNC(glDebugMessageCallbackARB)
2704 USE_GL_FUNC(glDebugMessageControlARB)
2705 USE_GL_FUNC(glDebugMessageInsertARB)
2706 USE_GL_FUNC(glGetDebugMessageLogARB)
2707 /* GL_ARB_draw_buffers */
2708 USE_GL_FUNC(glDrawBuffersARB)
2709 /* GL_ARB_draw_elements_base_vertex */
2710 USE_GL_FUNC(glDrawElementsBaseVertex)
2711 USE_GL_FUNC(glDrawElementsInstancedBaseVertex)
2712 USE_GL_FUNC(glDrawRangeElementsBaseVertex)
2713 USE_GL_FUNC(glMultiDrawElementsBaseVertex)
2714 /* GL_ARB_draw_instanced */
2715 USE_GL_FUNC(glDrawArraysInstancedARB)
2716 USE_GL_FUNC(glDrawElementsInstancedARB)
2717 /* GL_ARB_ES2_compatibility */
2718 USE_GL_FUNC(glReleaseShaderCompiler)
2719 USE_GL_FUNC(glShaderBinary)
2720 USE_GL_FUNC(glGetShaderPrecisionFormat)
2721 USE_GL_FUNC(glDepthRangef)
2722 USE_GL_FUNC(glClearDepthf)
2723 /* GL_ARB_framebuffer_object */
2724 USE_GL_FUNC(glBindFramebuffer)
2725 USE_GL_FUNC(glBindRenderbuffer)
2726 USE_GL_FUNC(glBlitFramebuffer)
2727 USE_GL_FUNC(glCheckFramebufferStatus)
2728 USE_GL_FUNC(glDeleteFramebuffers)
2729 USE_GL_FUNC(glDeleteRenderbuffers)
2730 USE_GL_FUNC(glFramebufferRenderbuffer)
2731 USE_GL_FUNC(glFramebufferTexture)
2732 USE_GL_FUNC(glFramebufferTexture1D)
2733 USE_GL_FUNC(glFramebufferTexture2D)
2734 USE_GL_FUNC(glFramebufferTexture3D)
2735 USE_GL_FUNC(glFramebufferTextureLayer)
2736 USE_GL_FUNC(glGenFramebuffers)
2737 USE_GL_FUNC(glGenRenderbuffers)
2738 USE_GL_FUNC(glGenerateMipmap)
2739 USE_GL_FUNC(glGetFramebufferAttachmentParameteriv)
2740 USE_GL_FUNC(glGetRenderbufferParameteriv)
2741 USE_GL_FUNC(glIsFramebuffer)
2742 USE_GL_FUNC(glIsRenderbuffer)
2743 USE_GL_FUNC(glRenderbufferStorage)
2744 USE_GL_FUNC(glRenderbufferStorageMultisample)
2745 /* GL_ARB_geometry_shader4 */
2746 USE_GL_FUNC(glFramebufferTextureARB)
2747 USE_GL_FUNC(glFramebufferTextureFaceARB)
2748 USE_GL_FUNC(glFramebufferTextureLayerARB)
2749 USE_GL_FUNC(glProgramParameteriARB)
2750 /* GL_ARB_instanced_arrays */
2751 USE_GL_FUNC(glVertexAttribDivisorARB)
2752 /* GL_ARB_internalformat_query */
2753 USE_GL_FUNC(glGetInternalformativ)
2754 /* GL_ARB_internalformat_query2 */
2755 USE_GL_FUNC(glGetInternalformati64v)
2756 /* GL_ARB_map_buffer_range */
2757 USE_GL_FUNC(glFlushMappedBufferRange)
2758 USE_GL_FUNC(glMapBufferRange)
2759 /* GL_ARB_multisample */
2760 USE_GL_FUNC(glSampleCoverageARB)
2761 /* GL_ARB_multitexture */
2762 USE_GL_FUNC(glActiveTextureARB)
2763 USE_GL_FUNC(glClientActiveTextureARB)
2764 USE_GL_FUNC(glMultiTexCoord1fARB)
2765 USE_GL_FUNC(glMultiTexCoord1fvARB)
2766 USE_GL_FUNC(glMultiTexCoord2fARB)
2767 USE_GL_FUNC(glMultiTexCoord2fvARB)
2768 USE_GL_FUNC(glMultiTexCoord2svARB)
2769 USE_GL_FUNC(glMultiTexCoord3fARB)
2770 USE_GL_FUNC(glMultiTexCoord3fvARB)
2771 USE_GL_FUNC(glMultiTexCoord4fARB)
2772 USE_GL_FUNC(glMultiTexCoord4fvARB)
2773 USE_GL_FUNC(glMultiTexCoord4svARB)
2774 /* GL_ARB_occlusion_query */
2775 USE_GL_FUNC(glBeginQueryARB)
2776 USE_GL_FUNC(glDeleteQueriesARB)
2777 USE_GL_FUNC(glEndQueryARB)
2778 USE_GL_FUNC(glGenQueriesARB)
2779 USE_GL_FUNC(glGetQueryivARB)
2780 USE_GL_FUNC(glGetQueryObjectivARB)
2781 USE_GL_FUNC(glGetQueryObjectuivARB)
2782 USE_GL_FUNC(glIsQueryARB)
2783 /* GL_ARB_point_parameters */
2784 USE_GL_FUNC(glPointParameterfARB)
2785 USE_GL_FUNC(glPointParameterfvARB)
2786 /* GL_ARB_provoking_vertex */
2787 USE_GL_FUNC(glProvokingVertex)
2788 /* GL_ARB_sampler_objects */
2789 USE_GL_FUNC(glGenSamplers)
2790 USE_GL_FUNC(glDeleteSamplers)
2791 USE_GL_FUNC(glIsSampler)
2792 USE_GL_FUNC(glBindSampler)
2793 USE_GL_FUNC(glSamplerParameteri)
2794 USE_GL_FUNC(glSamplerParameterf)
2795 USE_GL_FUNC(glSamplerParameteriv)
2796 USE_GL_FUNC(glSamplerParameterfv)
2797 USE_GL_FUNC(glSamplerParameterIiv)
2798 USE_GL_FUNC(glSamplerParameterIuiv)
2799 USE_GL_FUNC(glGetSamplerParameteriv)
2800 USE_GL_FUNC(glGetSamplerParameterfv)
2801 USE_GL_FUNC(glGetSamplerParameterIiv)
2802 USE_GL_FUNC(glGetSamplerParameterIuiv)
2803 /* GL_ARB_shader_atomic_counters */
2804 USE_GL_FUNC(glGetActiveAtomicCounterBufferiv)
2805 /* GL_ARB_shader_image_load_store */
2806 USE_GL_FUNC(glBindImageTexture)
2807 USE_GL_FUNC(glMemoryBarrier)
2808 /* GL_ARB_shader_objects */
2809 USE_GL_FUNC(glAttachObjectARB)
2810 USE_GL_FUNC(glBindAttribLocationARB)
2811 USE_GL_FUNC(glCompileShaderARB)
2812 USE_GL_FUNC(glCreateProgramObjectARB)
2813 USE_GL_FUNC(glCreateShaderObjectARB)
2814 USE_GL_FUNC(glDeleteObjectARB)
2815 USE_GL_FUNC(glDetachObjectARB)
2816 USE_GL_FUNC(glGetActiveUniformARB)
2817 USE_GL_FUNC(glGetAttachedObjectsARB)
2818 USE_GL_FUNC(glGetAttribLocationARB)
2819 USE_GL_FUNC(glGetHandleARB)
2820 USE_GL_FUNC(glGetInfoLogARB)
2821 USE_GL_FUNC(glGetObjectParameterfvARB)
2822 USE_GL_FUNC(glGetObjectParameterivARB)
2823 USE_GL_FUNC(glGetShaderSourceARB)
2824 USE_GL_FUNC(glGetUniformLocationARB)
2825 USE_GL_FUNC(glGetUniformfvARB)
2826 USE_GL_FUNC(glGetUniformivARB)
2827 USE_GL_FUNC(glLinkProgramARB)
2828 USE_GL_FUNC(glShaderSourceARB)
2829 USE_GL_FUNC(glUniform1fARB)
2830 USE_GL_FUNC(glUniform1fvARB)
2831 USE_GL_FUNC(glUniform1iARB)
2832 USE_GL_FUNC(glUniform1ivARB)
2833 USE_GL_FUNC(glUniform2fARB)
2834 USE_GL_FUNC(glUniform2fvARB)
2835 USE_GL_FUNC(glUniform2iARB)
2836 USE_GL_FUNC(glUniform2ivARB)
2837 USE_GL_FUNC(glUniform3fARB)
2838 USE_GL_FUNC(glUniform3fvARB)
2839 USE_GL_FUNC(glUniform3iARB)
2840 USE_GL_FUNC(glUniform3ivARB)
2841 USE_GL_FUNC(glUniform4fARB)
2842 USE_GL_FUNC(glUniform4fvARB)
2843 USE_GL_FUNC(glUniform4iARB)
2844 USE_GL_FUNC(glUniform4ivARB)
2845 USE_GL_FUNC(glUniformMatrix2fvARB)
2846 USE_GL_FUNC(glUniformMatrix3fvARB)
2847 USE_GL_FUNC(glUniformMatrix4fvARB)
2848 USE_GL_FUNC(glUseProgramObjectARB)
2849 USE_GL_FUNC(glValidateProgramARB)
2850 /* GL_ARB_shader_storage_buffer_object */
2851 USE_GL_FUNC(glShaderStorageBlockBinding)
2852 /* GL_ARB_sync */
2853 USE_GL_FUNC(glClientWaitSync)
2854 USE_GL_FUNC(glDeleteSync)
2855 USE_GL_FUNC(glFenceSync)
2856 USE_GL_FUNC(glGetInteger64v)
2857 USE_GL_FUNC(glGetSynciv)
2858 USE_GL_FUNC(glIsSync)
2859 USE_GL_FUNC(glWaitSync)
2860 /* GL_ARB_tessellation_shader */
2861 USE_GL_FUNC(glPatchParameteri)
2862 USE_GL_FUNC(glPatchParameterfv)
2863 /* GL_ARB_texture_buffer_object */
2864 USE_GL_FUNC(glTexBufferARB)
2865 /* GL_ARB_texture_buffer_range */
2866 USE_GL_FUNC(glTexBufferRange)
2867 /* GL_ARB_texture_compression */
2868 USE_GL_FUNC(glCompressedTexImage2DARB)
2869 USE_GL_FUNC(glCompressedTexImage3DARB)
2870 USE_GL_FUNC(glCompressedTexSubImage2DARB)
2871 USE_GL_FUNC(glCompressedTexSubImage3DARB)
2872 USE_GL_FUNC(glGetCompressedTexImageARB)
2873 /* GL_ARB_texture_storage */
2874 USE_GL_FUNC(glTexStorage1D)
2875 USE_GL_FUNC(glTexStorage2D)
2876 USE_GL_FUNC(glTexStorage3D)
2877 /* GL_ARB_texture_view */
2878 USE_GL_FUNC(glTextureView)
2879 /* GL_ARB_timer_query */
2880 USE_GL_FUNC(glQueryCounter)
2881 USE_GL_FUNC(glGetQueryObjectui64v)
2882 /* GL_ARB_transform_feedback2 */
2883 USE_GL_FUNC(glBindTransformFeedback);
2884 USE_GL_FUNC(glDeleteTransformFeedbacks);
2885 USE_GL_FUNC(glDrawTransformFeedback);
2886 USE_GL_FUNC(glGenTransformFeedbacks);
2887 USE_GL_FUNC(glIsTransformFeedback);
2888 USE_GL_FUNC(glPauseTransformFeedback);
2889 USE_GL_FUNC(glResumeTransformFeedback);
2890 /* GL_ARB_transform_feedback3 */
2891 USE_GL_FUNC(glBeginQueryIndexed);
2892 USE_GL_FUNC(glDrawTransformFeedbackStream);
2893 USE_GL_FUNC(glEndQueryIndexed);
2894 USE_GL_FUNC(glGetQueryIndexediv);
2895 /* GL_ARB_uniform_buffer_object */
2896 USE_GL_FUNC(glBindBufferBase)
2897 USE_GL_FUNC(glBindBufferRange)
2898 USE_GL_FUNC(glGetActiveUniformBlockName)
2899 USE_GL_FUNC(glGetActiveUniformBlockiv)
2900 USE_GL_FUNC(glGetActiveUniformName)
2901 USE_GL_FUNC(glGetActiveUniformsiv)
2902 USE_GL_FUNC(glGetIntegeri_v)
2903 USE_GL_FUNC(glGetUniformBlockIndex)
2904 USE_GL_FUNC(glGetUniformIndices)
2905 USE_GL_FUNC(glUniformBlockBinding)
2906 /* GL_ARB_vertex_blend */
2907 USE_GL_FUNC(glVertexBlendARB)
2908 USE_GL_FUNC(glWeightPointerARB)
2909 USE_GL_FUNC(glWeightbvARB)
2910 USE_GL_FUNC(glWeightdvARB)
2911 USE_GL_FUNC(glWeightfvARB)
2912 USE_GL_FUNC(glWeightivARB)
2913 USE_GL_FUNC(glWeightsvARB)
2914 USE_GL_FUNC(glWeightubvARB)
2915 USE_GL_FUNC(glWeightuivARB)
2916 USE_GL_FUNC(glWeightusvARB)
2917 /* GL_ARB_vertex_buffer_object */
2918 USE_GL_FUNC(glBindBufferARB)
2919 USE_GL_FUNC(glBufferDataARB)
2920 USE_GL_FUNC(glBufferSubDataARB)
2921 USE_GL_FUNC(glDeleteBuffersARB)
2922 USE_GL_FUNC(glGenBuffersARB)
2923 USE_GL_FUNC(glGetBufferParameterivARB)
2924 USE_GL_FUNC(glGetBufferPointervARB)
2925 USE_GL_FUNC(glGetBufferSubDataARB)
2926 USE_GL_FUNC(glIsBufferARB)
2927 USE_GL_FUNC(glMapBufferARB)
2928 USE_GL_FUNC(glUnmapBufferARB)
2929 /* GL_ARB_vertex_program */
2930 USE_GL_FUNC(glBindProgramARB)
2931 USE_GL_FUNC(glDeleteProgramsARB)
2932 USE_GL_FUNC(glDisableVertexAttribArrayARB)
2933 USE_GL_FUNC(glEnableVertexAttribArrayARB)
2934 USE_GL_FUNC(glGenProgramsARB)
2935 USE_GL_FUNC(glGetProgramivARB)
2936 USE_GL_FUNC(glProgramEnvParameter4fvARB)
2937 USE_GL_FUNC(glProgramLocalParameter4fvARB)
2938 USE_GL_FUNC(glProgramStringARB)
2939 USE_GL_FUNC(glVertexAttrib1dARB)
2940 USE_GL_FUNC(glVertexAttrib1dvARB)
2941 USE_GL_FUNC(glVertexAttrib1fARB)
2942 USE_GL_FUNC(glVertexAttrib1fvARB)
2943 USE_GL_FUNC(glVertexAttrib1sARB)
2944 USE_GL_FUNC(glVertexAttrib1svARB)
2945 USE_GL_FUNC(glVertexAttrib2dARB)
2946 USE_GL_FUNC(glVertexAttrib2dvARB)
2947 USE_GL_FUNC(glVertexAttrib2fARB)
2948 USE_GL_FUNC(glVertexAttrib2fvARB)
2949 USE_GL_FUNC(glVertexAttrib2sARB)
2950 USE_GL_FUNC(glVertexAttrib2svARB)
2951 USE_GL_FUNC(glVertexAttrib3dARB)
2952 USE_GL_FUNC(glVertexAttrib3dvARB)
2953 USE_GL_FUNC(glVertexAttrib3fARB)
2954 USE_GL_FUNC(glVertexAttrib3fvARB)
2955 USE_GL_FUNC(glVertexAttrib3sARB)
2956 USE_GL_FUNC(glVertexAttrib3svARB)
2957 USE_GL_FUNC(glVertexAttrib4NbvARB)
2958 USE_GL_FUNC(glVertexAttrib4NivARB)
2959 USE_GL_FUNC(glVertexAttrib4NsvARB)
2960 USE_GL_FUNC(glVertexAttrib4NubARB)
2961 USE_GL_FUNC(glVertexAttrib4NubvARB)
2962 USE_GL_FUNC(glVertexAttrib4NuivARB)
2963 USE_GL_FUNC(glVertexAttrib4NusvARB)
2964 USE_GL_FUNC(glVertexAttrib4bvARB)
2965 USE_GL_FUNC(glVertexAttrib4dARB)
2966 USE_GL_FUNC(glVertexAttrib4dvARB)
2967 USE_GL_FUNC(glVertexAttrib4fARB)
2968 USE_GL_FUNC(glVertexAttrib4fvARB)
2969 USE_GL_FUNC(glVertexAttrib4ivARB)
2970 USE_GL_FUNC(glVertexAttrib4sARB)
2971 USE_GL_FUNC(glVertexAttrib4svARB)
2972 USE_GL_FUNC(glVertexAttrib4ubvARB)
2973 USE_GL_FUNC(glVertexAttrib4uivARB)
2974 USE_GL_FUNC(glVertexAttrib4usvARB)
2975 USE_GL_FUNC(glVertexAttribPointerARB)
2976 /* GL_ARB_viewport_array */
2977 USE_GL_FUNC(glDepthRangeArrayv)
2978 USE_GL_FUNC(glDepthRangeIndexed)
2979 USE_GL_FUNC(glGetDoublei_v)
2980 USE_GL_FUNC(glGetFloati_v)
2981 USE_GL_FUNC(glScissorArrayv)
2982 USE_GL_FUNC(glScissorIndexed)
2983 USE_GL_FUNC(glScissorIndexedv)
2984 USE_GL_FUNC(glViewportArrayv)
2985 USE_GL_FUNC(glViewportIndexedf)
2986 USE_GL_FUNC(glViewportIndexedfv)
2987 /* GL_ATI_fragment_shader */
2988 USE_GL_FUNC(glAlphaFragmentOp1ATI)
2989 USE_GL_FUNC(glAlphaFragmentOp2ATI)
2990 USE_GL_FUNC(glAlphaFragmentOp3ATI)
2991 USE_GL_FUNC(glBeginFragmentShaderATI)
2992 USE_GL_FUNC(glBindFragmentShaderATI)
2993 USE_GL_FUNC(glColorFragmentOp1ATI)
2994 USE_GL_FUNC(glColorFragmentOp2ATI)
2995 USE_GL_FUNC(glColorFragmentOp3ATI)
2996 USE_GL_FUNC(glDeleteFragmentShaderATI)
2997 USE_GL_FUNC(glEndFragmentShaderATI)
2998 USE_GL_FUNC(glGenFragmentShadersATI)
2999 USE_GL_FUNC(glPassTexCoordATI)
3000 USE_GL_FUNC(glSampleMapATI)
3001 USE_GL_FUNC(glSetFragmentShaderConstantATI)
3002 /* GL_ATI_separate_stencil */
3003 USE_GL_FUNC(glStencilOpSeparateATI)
3004 USE_GL_FUNC(glStencilFuncSeparateATI)
3005 /* GL_EXT_blend_color */
3006 USE_GL_FUNC(glBlendColorEXT)
3007 /* GL_EXT_blend_equation_separate */
3008 USE_GL_FUNC(glBlendFuncSeparateEXT)
3009 /* GL_EXT_blend_func_separate */
3010 USE_GL_FUNC(glBlendEquationSeparateEXT)
3011 /* GL_EXT_blend_minmax */
3012 USE_GL_FUNC(glBlendEquationEXT)
3013 /* GL_EXT_depth_bounds_test */
3014 USE_GL_FUNC(glDepthBoundsEXT)
3015 /* GL_EXT_draw_buffers2 */
3016 USE_GL_FUNC(glColorMaskIndexedEXT)
3017 USE_GL_FUNC(glDisableIndexedEXT)
3018 USE_GL_FUNC(glEnableIndexedEXT)
3019 USE_GL_FUNC(glGetBooleanIndexedvEXT)
3020 USE_GL_FUNC(glGetIntegerIndexedvEXT)
3021 USE_GL_FUNC(glIsEnabledIndexedEXT)
3022 /* GL_EXT_fog_coord */
3023 USE_GL_FUNC(glFogCoordPointerEXT)
3024 USE_GL_FUNC(glFogCoorddEXT)
3025 USE_GL_FUNC(glFogCoorddvEXT)
3026 USE_GL_FUNC(glFogCoordfEXT)
3027 USE_GL_FUNC(glFogCoordfvEXT)
3028 /* GL_EXT_framebuffer_blit */
3029 USE_GL_FUNC(glBlitFramebufferEXT)
3030 /* GL_EXT_framebuffer_multisample */
3031 USE_GL_FUNC(glRenderbufferStorageMultisampleEXT)
3032 /* GL_EXT_framebuffer_object */
3033 USE_GL_FUNC(glBindFramebufferEXT)
3034 USE_GL_FUNC(glBindRenderbufferEXT)
3035 USE_GL_FUNC(glCheckFramebufferStatusEXT)
3036 USE_GL_FUNC(glDeleteFramebuffersEXT)
3037 USE_GL_FUNC(glDeleteRenderbuffersEXT)
3038 USE_GL_FUNC(glFramebufferRenderbufferEXT)
3039 USE_GL_FUNC(glFramebufferTexture1DEXT)
3040 USE_GL_FUNC(glFramebufferTexture2DEXT)
3041 USE_GL_FUNC(glFramebufferTexture3DEXT)
3042 USE_GL_FUNC(glGenFramebuffersEXT)
3043 USE_GL_FUNC(glGenRenderbuffersEXT)
3044 USE_GL_FUNC(glGenerateMipmapEXT)
3045 USE_GL_FUNC(glGetFramebufferAttachmentParameterivEXT)
3046 USE_GL_FUNC(glGetRenderbufferParameterivEXT)
3047 USE_GL_FUNC(glIsFramebufferEXT)
3048 USE_GL_FUNC(glIsRenderbufferEXT)
3049 USE_GL_FUNC(glRenderbufferStorageEXT)
3050 /* GL_EXT_gpu_program_parameters */
3051 USE_GL_FUNC(glProgramEnvParameters4fvEXT)
3052 USE_GL_FUNC(glProgramLocalParameters4fvEXT)
3053 /* GL_EXT_gpu_shader4 */
3054 USE_GL_FUNC(glBindFragDataLocationEXT)
3055 USE_GL_FUNC(glGetFragDataLocationEXT)
3056 USE_GL_FUNC(glGetUniformuivEXT)
3057 USE_GL_FUNC(glGetVertexAttribIivEXT)
3058 USE_GL_FUNC(glGetVertexAttribIuivEXT)
3059 USE_GL_FUNC(glUniform1uiEXT)
3060 USE_GL_FUNC(glUniform1uivEXT)
3061 USE_GL_FUNC(glUniform2uiEXT)
3062 USE_GL_FUNC(glUniform2uivEXT)
3063 USE_GL_FUNC(glUniform3uiEXT)
3064 USE_GL_FUNC(glUniform3uivEXT)
3065 USE_GL_FUNC(glUniform4uiEXT)
3066 USE_GL_FUNC(glUniform4uivEXT)
3067 USE_GL_FUNC(glVertexAttribI1iEXT)
3068 USE_GL_FUNC(glVertexAttribI1ivEXT)
3069 USE_GL_FUNC(glVertexAttribI1uiEXT)
3070 USE_GL_FUNC(glVertexAttribI1uivEXT)
3071 USE_GL_FUNC(glVertexAttribI2iEXT)
3072 USE_GL_FUNC(glVertexAttribI2ivEXT)
3073 USE_GL_FUNC(glVertexAttribI2uiEXT)
3074 USE_GL_FUNC(glVertexAttribI2uivEXT)
3075 USE_GL_FUNC(glVertexAttribI3iEXT)
3076 USE_GL_FUNC(glVertexAttribI3ivEXT)
3077 USE_GL_FUNC(glVertexAttribI3uiEXT)
3078 USE_GL_FUNC(glVertexAttribI3uivEXT)
3079 USE_GL_FUNC(glVertexAttribI4bvEXT)
3080 USE_GL_FUNC(glVertexAttribI4iEXT)
3081 USE_GL_FUNC(glVertexAttribI4ivEXT)
3082 USE_GL_FUNC(glVertexAttribI4svEXT)
3083 USE_GL_FUNC(glVertexAttribI4ubvEXT)
3084 USE_GL_FUNC(glVertexAttribI4uiEXT)
3085 USE_GL_FUNC(glVertexAttribI4uivEXT)
3086 USE_GL_FUNC(glVertexAttribI4usvEXT)
3087 USE_GL_FUNC(glVertexAttribIPointerEXT)
3088 /* GL_EXT_point_parameters */
3089 USE_GL_FUNC(glPointParameterfEXT)
3090 USE_GL_FUNC(glPointParameterfvEXT)
3091 /* GL_EXT_provoking_vertex */
3092 USE_GL_FUNC(glProvokingVertexEXT)
3093 /* GL_EXT_secondary_color */
3094 USE_GL_FUNC(glSecondaryColor3fEXT)
3095 USE_GL_FUNC(glSecondaryColor3fvEXT)
3096 USE_GL_FUNC(glSecondaryColor3ubEXT)
3097 USE_GL_FUNC(glSecondaryColor3ubvEXT)
3098 USE_GL_FUNC(glSecondaryColorPointerEXT)
3099 /* GL_EXT_stencil_two_side */
3100 USE_GL_FUNC(glActiveStencilFaceEXT)
3101 /* GL_EXT_texture3D */
3102 USE_GL_FUNC(glTexImage3D)
3103 USE_GL_FUNC(glTexImage3DEXT)
3104 USE_GL_FUNC(glTexSubImage3D)
3105 USE_GL_FUNC(glTexSubImage3DEXT)
3106 /* GL_NV_fence */
3107 USE_GL_FUNC(glDeleteFencesNV)
3108 USE_GL_FUNC(glFinishFenceNV)
3109 USE_GL_FUNC(glGenFencesNV)
3110 USE_GL_FUNC(glGetFenceivNV)
3111 USE_GL_FUNC(glIsFenceNV)
3112 USE_GL_FUNC(glSetFenceNV)
3113 USE_GL_FUNC(glTestFenceNV)
3114 /* GL_NV_half_float */
3115 USE_GL_FUNC(glColor3hNV)
3116 USE_GL_FUNC(glColor3hvNV)
3117 USE_GL_FUNC(glColor4hNV)
3118 USE_GL_FUNC(glColor4hvNV)
3119 USE_GL_FUNC(glFogCoordhNV)
3120 USE_GL_FUNC(glFogCoordhvNV)
3121 USE_GL_FUNC(glMultiTexCoord1hNV)
3122 USE_GL_FUNC(glMultiTexCoord1hvNV)
3123 USE_GL_FUNC(glMultiTexCoord2hNV)
3124 USE_GL_FUNC(glMultiTexCoord2hvNV)
3125 USE_GL_FUNC(glMultiTexCoord3hNV)
3126 USE_GL_FUNC(glMultiTexCoord3hvNV)
3127 USE_GL_FUNC(glMultiTexCoord4hNV)
3128 USE_GL_FUNC(glMultiTexCoord4hvNV)
3129 USE_GL_FUNC(glNormal3hNV)
3130 USE_GL_FUNC(glNormal3hvNV)
3131 USE_GL_FUNC(glSecondaryColor3hNV)
3132 USE_GL_FUNC(glSecondaryColor3hvNV)
3133 USE_GL_FUNC(glTexCoord1hNV)
3134 USE_GL_FUNC(glTexCoord1hvNV)
3135 USE_GL_FUNC(glTexCoord2hNV)
3136 USE_GL_FUNC(glTexCoord2hvNV)
3137 USE_GL_FUNC(glTexCoord3hNV)
3138 USE_GL_FUNC(glTexCoord3hvNV)
3139 USE_GL_FUNC(glTexCoord4hNV)
3140 USE_GL_FUNC(glTexCoord4hvNV)
3141 USE_GL_FUNC(glVertex2hNV)
3142 USE_GL_FUNC(glVertex2hvNV)
3143 USE_GL_FUNC(glVertex3hNV)
3144 USE_GL_FUNC(glVertex3hvNV)
3145 USE_GL_FUNC(glVertex4hNV)
3146 USE_GL_FUNC(glVertex4hvNV)
3147 USE_GL_FUNC(glVertexAttrib1hNV)
3148 USE_GL_FUNC(glVertexAttrib1hvNV)
3149 USE_GL_FUNC(glVertexAttrib2hNV)
3150 USE_GL_FUNC(glVertexAttrib2hvNV)
3151 USE_GL_FUNC(glVertexAttrib3hNV)
3152 USE_GL_FUNC(glVertexAttrib3hvNV)
3153 USE_GL_FUNC(glVertexAttrib4hNV)
3154 USE_GL_FUNC(glVertexAttrib4hvNV)
3155 USE_GL_FUNC(glVertexAttribs1hvNV)
3156 USE_GL_FUNC(glVertexAttribs2hvNV)
3157 USE_GL_FUNC(glVertexAttribs3hvNV)
3158 USE_GL_FUNC(glVertexAttribs4hvNV)
3159 USE_GL_FUNC(glVertexWeighthNV)
3160 USE_GL_FUNC(glVertexWeighthvNV)
3161 /* GL_NV_point_sprite */
3162 USE_GL_FUNC(glPointParameteriNV)
3163 USE_GL_FUNC(glPointParameterivNV)
3164 /* GL_NV_register_combiners */
3165 USE_GL_FUNC(glCombinerInputNV)
3166 USE_GL_FUNC(glCombinerOutputNV)
3167 USE_GL_FUNC(glCombinerParameterfNV)
3168 USE_GL_FUNC(glCombinerParameterfvNV)
3169 USE_GL_FUNC(glCombinerParameteriNV)
3170 USE_GL_FUNC(glCombinerParameterivNV)
3171 USE_GL_FUNC(glFinalCombinerInputNV)
3172 /* WGL extensions */
3173 USE_GL_FUNC(wglChoosePixelFormatARB)
3174 USE_GL_FUNC(wglGetExtensionsStringARB)
3175 USE_GL_FUNC(wglGetPixelFormatAttribfvARB)
3176 USE_GL_FUNC(wglGetPixelFormatAttribivARB)
3177 USE_GL_FUNC(wglQueryCurrentRendererIntegerWINE)
3178 USE_GL_FUNC(wglQueryCurrentRendererStringWINE)
3179 USE_GL_FUNC(wglQueryRendererIntegerWINE)
3180 USE_GL_FUNC(wglQueryRendererStringWINE)
3181 USE_GL_FUNC(wglSetPixelFormatWINE)
3182 USE_GL_FUNC(wglSwapIntervalEXT)
3184 /* Newer core functions */
3185 USE_GL_FUNC(glActiveTexture) /* OpenGL 1.3 */
3186 USE_GL_FUNC(glAttachShader) /* OpenGL 2.0 */
3187 USE_GL_FUNC(glBeginQuery) /* OpenGL 1.5 */
3188 USE_GL_FUNC(glBeginTransformFeedback) /* OpenGL 3.0 */
3189 USE_GL_FUNC(glBindAttribLocation) /* OpenGL 2.0 */
3190 USE_GL_FUNC(glBindBuffer) /* OpenGL 1.5 */
3191 USE_GL_FUNC(glBindFragDataLocation) /* OpenGL 3.0 */
3192 USE_GL_FUNC(glBindVertexArray) /* OpenGL 3.0 */
3193 USE_GL_FUNC(glBlendColor) /* OpenGL 1.4 */
3194 USE_GL_FUNC(glBlendEquation) /* OpenGL 1.4 */
3195 USE_GL_FUNC(glBlendEquationSeparate) /* OpenGL 2.0 */
3196 USE_GL_FUNC(glBlendFuncSeparate) /* OpenGL 1.4 */
3197 USE_GL_FUNC(glBufferData) /* OpenGL 1.5 */
3198 USE_GL_FUNC(glBufferSubData) /* OpenGL 1.5 */
3199 USE_GL_FUNC(glColorMaski) /* OpenGL 3.0 */
3200 USE_GL_FUNC(glCompileShader) /* OpenGL 2.0 */
3201 USE_GL_FUNC(glCompressedTexImage2D) /* OpenGL 1.3 */
3202 USE_GL_FUNC(glCompressedTexImage3D) /* OpenGL 1.3 */
3203 USE_GL_FUNC(glCompressedTexSubImage2D) /* OpenGL 1.3 */
3204 USE_GL_FUNC(glCompressedTexSubImage3D) /* OpenGL 1.3 */
3205 USE_GL_FUNC(glCreateProgram) /* OpenGL 2.0 */
3206 USE_GL_FUNC(glCreateShader) /* OpenGL 2.0 */
3207 USE_GL_FUNC(glDebugMessageCallback) /* OpenGL 4.3 */
3208 USE_GL_FUNC(glDebugMessageControl) /* OpenGL 4.3 */
3209 USE_GL_FUNC(glDebugMessageInsert) /* OpenGL 4.3 */
3210 USE_GL_FUNC(glDeleteBuffers) /* OpenGL 1.5 */
3211 USE_GL_FUNC(glDeleteProgram) /* OpenGL 2.0 */
3212 USE_GL_FUNC(glDeleteQueries) /* OpenGL 1.5 */
3213 USE_GL_FUNC(glDeleteShader) /* OpenGL 2.0 */
3214 USE_GL_FUNC(glDeleteVertexArrays) /* OpenGL 3.0 */
3215 USE_GL_FUNC(glDetachShader) /* OpenGL 2.0 */
3216 USE_GL_FUNC(glDisablei) /* OpenGL 3.0 */
3217 USE_GL_FUNC(glDisableVertexAttribArray) /* OpenGL 2.0 */
3218 USE_GL_FUNC(glDrawArraysInstanced) /* OpenGL 3.1 */
3219 USE_GL_FUNC(glDrawBuffers) /* OpenGL 2.0 */
3220 USE_GL_FUNC(glDrawElementsInstanced) /* OpenGL 3.1 */
3221 USE_GL_FUNC(glEnablei) /* OpenGL 3.0 */
3222 USE_GL_FUNC(glEnableVertexAttribArray) /* OpenGL 2.0 */
3223 USE_GL_FUNC(glEndQuery) /* OpenGL 1.5 */
3224 USE_GL_FUNC(glEndTransformFeedback) /* OpenGL 3.0 */
3225 USE_GL_FUNC(glFramebufferTexture) /* OpenGL 3.2 */
3226 USE_GL_FUNC(glGenBuffers) /* OpenGL 1.5 */
3227 USE_GL_FUNC(glGenQueries) /* OpenGL 1.5 */
3228 USE_GL_FUNC(glGenVertexArrays) /* OpenGL 3.0 */
3229 USE_GL_FUNC(glGetActiveUniform) /* OpenGL 2.0 */
3230 USE_GL_FUNC(glGetAttachedShaders) /* OpenGL 2.0 */
3231 USE_GL_FUNC(glGetAttribLocation) /* OpenGL 2.0 */
3232 USE_GL_FUNC(glGetBooleani_v) /* OpenGL 3.0 */
3233 USE_GL_FUNC(glGetBufferSubData) /* OpenGL 1.5 */
3234 USE_GL_FUNC(glGetCompressedTexImage) /* OpenGL 1.3 */
3235 USE_GL_FUNC(glGetDebugMessageLog) /* OpenGL 4.3 */
3236 USE_GL_FUNC(glGetIntegeri_v) /* OpenGL 3.0 */
3237 USE_GL_FUNC(glGetProgramInfoLog) /* OpenGL 2.0 */
3238 USE_GL_FUNC(glGetProgramiv) /* OpenGL 2.0 */
3239 USE_GL_FUNC(glGetQueryiv) /* OpenGL 1.5 */
3240 USE_GL_FUNC(glGetQueryObjectuiv) /* OpenGL 1.5 */
3241 USE_GL_FUNC(glGetShaderInfoLog) /* OpenGL 2.0 */
3242 USE_GL_FUNC(glGetShaderiv) /* OpenGL 2.0 */
3243 USE_GL_FUNC(glGetShaderSource) /* OpenGL 2.0 */
3244 USE_GL_FUNC(glGetStringi) /* OpenGL 3.0 */
3245 USE_GL_FUNC(glGetUniformfv) /* OpenGL 2.0 */
3246 USE_GL_FUNC(glGetUniformiv) /* OpenGL 2.0 */
3247 USE_GL_FUNC(glGetUniformLocation) /* OpenGL 2.0 */
3248 USE_GL_FUNC(glIsEnabledi) /* OpenGL 3.0 */
3249 USE_GL_FUNC(glLinkProgram) /* OpenGL 2.0 */
3250 USE_GL_FUNC(glMapBuffer) /* OpenGL 1.5 */
3251 USE_GL_FUNC(glPointParameteri) /* OpenGL 1.4 */
3252 USE_GL_FUNC(glPointParameteriv) /* OpenGL 1.4 */
3253 USE_GL_FUNC(glShaderSource) /* OpenGL 2.0 */
3254 USE_GL_FUNC(glStencilFuncSeparate) /* OpenGL 2.0 */
3255 USE_GL_FUNC(glStencilOpSeparate) /* OpenGL 2.0 */
3256 USE_GL_FUNC(glTexBuffer) /* OpenGL 3.1 */
3257 USE_GL_FUNC(glTexImage3D) /* OpenGL 1.2 */
3258 USE_GL_FUNC(glTexSubImage3D) /* OpenGL 1.2 */
3259 USE_GL_FUNC(glTransformFeedbackVaryings)/* OpenGL 3.0 */
3260 USE_GL_FUNC(glUniform1f) /* OpenGL 2.0 */
3261 USE_GL_FUNC(glUniform1fv) /* OpenGL 2.0 */
3262 USE_GL_FUNC(glUniform1i) /* OpenGL 2.0 */
3263 USE_GL_FUNC(glUniform1iv) /* OpenGL 2.0 */
3264 USE_GL_FUNC(glUniform2f) /* OpenGL 2.0 */
3265 USE_GL_FUNC(glUniform2fv) /* OpenGL 2.0 */
3266 USE_GL_FUNC(glUniform2i) /* OpenGL 2.0 */
3267 USE_GL_FUNC(glUniform2iv) /* OpenGL 2.0 */
3268 USE_GL_FUNC(glUniform3f) /* OpenGL 2.0 */
3269 USE_GL_FUNC(glUniform3fv) /* OpenGL 2.0 */
3270 USE_GL_FUNC(glUniform3i) /* OpenGL 2.0 */
3271 USE_GL_FUNC(glUniform3iv) /* OpenGL 2.0 */
3272 USE_GL_FUNC(glUniform4f) /* OpenGL 2.0 */
3273 USE_GL_FUNC(glUniform4fv) /* OpenGL 2.0 */
3274 USE_GL_FUNC(glUniform4i) /* OpenGL 2.0 */
3275 USE_GL_FUNC(glUniform4iv) /* OpenGL 2.0 */
3276 USE_GL_FUNC(glUniformMatrix2fv) /* OpenGL 2.0 */
3277 USE_GL_FUNC(glUniformMatrix3fv) /* OpenGL 2.0 */
3278 USE_GL_FUNC(glUniformMatrix4fv) /* OpenGL 2.0 */
3279 USE_GL_FUNC(glUnmapBuffer) /* OpenGL 1.5 */
3280 USE_GL_FUNC(glUseProgram) /* OpenGL 2.0 */
3281 USE_GL_FUNC(glValidateProgram) /* OpenGL 2.0 */
3282 USE_GL_FUNC(glVertexAttrib1f) /* OpenGL 2.0 */
3283 USE_GL_FUNC(glVertexAttrib1fv) /* OpenGL 2.0 */
3284 USE_GL_FUNC(glVertexAttrib2f) /* OpenGL 2.0 */
3285 USE_GL_FUNC(glVertexAttrib2fv) /* OpenGL 2.0 */
3286 USE_GL_FUNC(glVertexAttrib3f) /* OpenGL 2.0 */
3287 USE_GL_FUNC(glVertexAttrib3fv) /* OpenGL 2.0 */
3288 USE_GL_FUNC(glVertexAttrib4f) /* OpenGL 2.0 */
3289 USE_GL_FUNC(glVertexAttrib4fv) /* OpenGL 2.0 */
3290 USE_GL_FUNC(glVertexAttrib4Nsv) /* OpenGL 2.0 */
3291 USE_GL_FUNC(glVertexAttrib4Nub) /* OpenGL 2.0 */
3292 USE_GL_FUNC(glVertexAttrib4Nubv) /* OpenGL 2.0 */
3293 USE_GL_FUNC(glVertexAttrib4Nusv) /* OpenGL 2.0 */
3294 USE_GL_FUNC(glVertexAttrib4sv) /* OpenGL 2.0 */
3295 USE_GL_FUNC(glVertexAttrib4ubv) /* OpenGL 2.0 */
3296 USE_GL_FUNC(glVertexAttribDivisor) /* OpenGL 3.3 */
3297 USE_GL_FUNC(glVertexAttribIPointer) /* OpenGL 3.0 */
3298 USE_GL_FUNC(glVertexAttribPointer) /* OpenGL 2.0 */
3299 #undef USE_GL_FUNC
3301 #ifndef USE_WIN32_OPENGL
3302 /* hack: use the functions directly from the TEB table to bypass the thunks */
3303 /* note that we still need the above wglGetProcAddress calls to initialize the table */
3304 gl_info->gl_ops.ext = ((struct opengl_funcs *)NtCurrentTeb()->glTable)->ext;
3305 #endif
3307 #define MAP_GL_FUNCTION(core_func, ext_func) \
3308 do \
3310 if (!gl_info->gl_ops.ext.p_##core_func) \
3311 gl_info->gl_ops.ext.p_##core_func = gl_info->gl_ops.ext.p_##ext_func; \
3312 } while (0)
3313 #define MAP_GL_FUNCTION_CAST(core_func, ext_func) \
3314 do \
3316 if (!gl_info->gl_ops.ext.p_##core_func) \
3317 gl_info->gl_ops.ext.p_##core_func = (void *)gl_info->gl_ops.ext.p_##ext_func; \
3318 } while (0)
3320 MAP_GL_FUNCTION(glActiveTexture, glActiveTextureARB);
3321 MAP_GL_FUNCTION(glAttachShader, glAttachObjectARB);
3322 MAP_GL_FUNCTION(glBeginQuery, glBeginQueryARB);
3323 MAP_GL_FUNCTION(glBindAttribLocation, glBindAttribLocationARB);
3324 MAP_GL_FUNCTION(glBindBuffer, glBindBufferARB);
3325 MAP_GL_FUNCTION(glBindFragDataLocation, glBindFragDataLocationEXT);
3326 MAP_GL_FUNCTION(glBlendColor, glBlendColorEXT);
3327 MAP_GL_FUNCTION(glBlendEquation, glBlendEquationEXT);
3328 MAP_GL_FUNCTION(glBlendEquationSeparate, glBlendEquationSeparateEXT);
3329 MAP_GL_FUNCTION(glBlendFuncSeparate, glBlendFuncSeparateEXT);
3330 MAP_GL_FUNCTION(glBufferData, glBufferDataARB);
3331 MAP_GL_FUNCTION(glBufferSubData, glBufferSubDataARB);
3332 MAP_GL_FUNCTION(glColorMaski, glColorMaskIndexedEXT);
3333 MAP_GL_FUNCTION(glCompileShader, glCompileShaderARB);
3334 MAP_GL_FUNCTION(glCompressedTexImage2D, glCompressedTexImage2DARB);
3335 MAP_GL_FUNCTION(glCompressedTexImage3D, glCompressedTexImage3DARB);
3336 MAP_GL_FUNCTION(glCompressedTexSubImage2D, glCompressedTexSubImage2DARB);
3337 MAP_GL_FUNCTION(glCompressedTexSubImage3D, glCompressedTexSubImage3DARB);
3338 MAP_GL_FUNCTION(glCreateProgram, glCreateProgramObjectARB);
3339 MAP_GL_FUNCTION(glCreateShader, glCreateShaderObjectARB);
3340 MAP_GL_FUNCTION(glDebugMessageCallback, glDebugMessageCallbackARB);
3341 MAP_GL_FUNCTION(glDebugMessageControl, glDebugMessageControlARB);
3342 MAP_GL_FUNCTION(glDebugMessageInsert, glDebugMessageInsertARB);
3343 MAP_GL_FUNCTION(glDeleteBuffers, glDeleteBuffersARB);
3344 MAP_GL_FUNCTION(glDeleteProgram, glDeleteObjectARB);
3345 MAP_GL_FUNCTION(glDeleteQueries, glDeleteQueriesARB);
3346 MAP_GL_FUNCTION(glDeleteShader, glDeleteObjectARB);
3347 MAP_GL_FUNCTION(glDetachShader, glDetachObjectARB);
3348 MAP_GL_FUNCTION(glDisablei, glDisableIndexedEXT);
3349 MAP_GL_FUNCTION(glDisableVertexAttribArray, glDisableVertexAttribArrayARB);
3350 MAP_GL_FUNCTION(glDrawArraysInstanced, glDrawArraysInstancedARB);
3351 MAP_GL_FUNCTION(glDrawBuffers, glDrawBuffersARB);
3352 MAP_GL_FUNCTION(glDrawElementsInstanced, glDrawElementsInstancedARB);
3353 MAP_GL_FUNCTION(glEnablei, glEnableIndexedEXT);
3354 MAP_GL_FUNCTION(glEnableVertexAttribArray, glEnableVertexAttribArrayARB);
3355 MAP_GL_FUNCTION(glEndQuery, glEndQueryARB);
3356 MAP_GL_FUNCTION(glFramebufferTexture, glFramebufferTextureARB);
3357 MAP_GL_FUNCTION(glGenBuffers, glGenBuffersARB);
3358 MAP_GL_FUNCTION(glGenQueries, glGenQueriesARB);
3359 MAP_GL_FUNCTION(glGetActiveUniform, glGetActiveUniformARB);
3360 MAP_GL_FUNCTION(glGetAttachedShaders, glGetAttachedObjectsARB);
3361 MAP_GL_FUNCTION(glGetAttribLocation, glGetAttribLocationARB);
3362 MAP_GL_FUNCTION(glGetBooleani_v, glGetBooleanIndexedvEXT);
3363 MAP_GL_FUNCTION(glGetBufferSubData, glGetBufferSubDataARB);
3364 MAP_GL_FUNCTION(glGetCompressedTexImage, glGetCompressedTexImageARB);
3365 MAP_GL_FUNCTION(glGetDebugMessageLog, glGetDebugMessageLogARB);
3366 MAP_GL_FUNCTION(glGetIntegeri_v, glGetIntegerIndexedvEXT);
3367 MAP_GL_FUNCTION(glGetProgramInfoLog, glGetInfoLogARB);
3368 MAP_GL_FUNCTION(glGetProgramiv, glGetObjectParameterivARB);
3369 MAP_GL_FUNCTION(glGetQueryiv, glGetQueryivARB);
3370 MAP_GL_FUNCTION(glGetQueryObjectuiv, glGetQueryObjectuivARB);
3371 MAP_GL_FUNCTION(glGetShaderInfoLog, glGetInfoLogARB);
3372 MAP_GL_FUNCTION(glGetShaderiv, glGetObjectParameterivARB);
3373 MAP_GL_FUNCTION(glGetShaderSource, glGetShaderSourceARB);
3374 MAP_GL_FUNCTION(glGetUniformfv, glGetUniformfvARB);
3375 MAP_GL_FUNCTION(glGetUniformiv, glGetUniformivARB);
3376 MAP_GL_FUNCTION(glGetUniformLocation, glGetUniformLocationARB);
3377 MAP_GL_FUNCTION(glIsEnabledi, glIsEnabledIndexedEXT);
3378 MAP_GL_FUNCTION(glLinkProgram, glLinkProgramARB);
3379 MAP_GL_FUNCTION(glMapBuffer, glMapBufferARB);
3380 MAP_GL_FUNCTION_CAST(glShaderSource, glShaderSourceARB);
3381 MAP_GL_FUNCTION(glTexBuffer, glTexBufferARB);
3382 MAP_GL_FUNCTION_CAST(glTexImage3D, glTexImage3DEXT);
3383 MAP_GL_FUNCTION(glTexSubImage3D, glTexSubImage3DEXT);
3384 MAP_GL_FUNCTION(glUniform1f, glUniform1fARB);
3385 MAP_GL_FUNCTION(glUniform1fv, glUniform1fvARB);
3386 MAP_GL_FUNCTION(glUniform1i, glUniform1iARB);
3387 MAP_GL_FUNCTION(glUniform1iv, glUniform1ivARB);
3388 MAP_GL_FUNCTION(glUniform2f, glUniform2fARB);
3389 MAP_GL_FUNCTION(glUniform2fv, glUniform2fvARB);
3390 MAP_GL_FUNCTION(glUniform2i, glUniform2iARB);
3391 MAP_GL_FUNCTION(glUniform2iv, glUniform2ivARB);
3392 MAP_GL_FUNCTION(glUniform3f, glUniform3fARB);
3393 MAP_GL_FUNCTION(glUniform3fv, glUniform3fvARB);
3394 MAP_GL_FUNCTION(glUniform3i, glUniform3iARB);
3395 MAP_GL_FUNCTION(glUniform3iv, glUniform3ivARB);
3396 MAP_GL_FUNCTION(glUniform4f, glUniform4fARB);
3397 MAP_GL_FUNCTION(glUniform4fv, glUniform4fvARB);
3398 MAP_GL_FUNCTION(glUniform4i, glUniform4iARB);
3399 MAP_GL_FUNCTION(glUniform4iv, glUniform4ivARB);
3400 MAP_GL_FUNCTION(glUniformMatrix2fv, glUniformMatrix2fvARB);
3401 MAP_GL_FUNCTION(glUniformMatrix3fv, glUniformMatrix3fvARB);
3402 MAP_GL_FUNCTION(glUniformMatrix4fv, glUniformMatrix4fvARB);
3403 MAP_GL_FUNCTION(glUnmapBuffer, glUnmapBufferARB);
3404 MAP_GL_FUNCTION(glUseProgram, glUseProgramObjectARB);
3405 MAP_GL_FUNCTION(glValidateProgram, glValidateProgramARB);
3406 MAP_GL_FUNCTION(glVertexAttrib1f, glVertexAttrib1fARB);
3407 MAP_GL_FUNCTION(glVertexAttrib1fv, glVertexAttrib1fvARB);
3408 MAP_GL_FUNCTION(glVertexAttrib2f, glVertexAttrib2fARB);
3409 MAP_GL_FUNCTION(glVertexAttrib2fv, glVertexAttrib2fvARB);
3410 MAP_GL_FUNCTION(glVertexAttrib3f, glVertexAttrib3fARB);
3411 MAP_GL_FUNCTION(glVertexAttrib3fv, glVertexAttrib3fvARB);
3412 MAP_GL_FUNCTION(glVertexAttrib4f, glVertexAttrib4fARB);
3413 MAP_GL_FUNCTION(glVertexAttrib4fv, glVertexAttrib4fvARB);
3414 MAP_GL_FUNCTION(glVertexAttrib4Nsv, glVertexAttrib4NsvARB);
3415 MAP_GL_FUNCTION(glVertexAttrib4Nub, glVertexAttrib4NubARB);
3416 MAP_GL_FUNCTION(glVertexAttrib4Nubv, glVertexAttrib4NubvARB);
3417 MAP_GL_FUNCTION(glVertexAttrib4Nusv, glVertexAttrib4NusvARB);
3418 MAP_GL_FUNCTION(glVertexAttrib4sv, glVertexAttrib4svARB);
3419 MAP_GL_FUNCTION(glVertexAttrib4ubv, glVertexAttrib4ubvARB);
3420 MAP_GL_FUNCTION(glVertexAttribDivisor, glVertexAttribDivisorARB);
3421 MAP_GL_FUNCTION(glVertexAttribIPointer, glVertexAttribIPointerEXT);
3422 MAP_GL_FUNCTION(glVertexAttribPointer, glVertexAttribPointerARB);
3423 #undef MAP_GL_FUNCTION
3424 #undef MAP_GL_FUNCTION_CAST
3427 static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
3429 unsigned int i, sampler_count;
3430 GLfloat gl_floatv[2];
3431 GLint gl_max;
3433 gl_info->limits.blends = 1;
3434 gl_info->limits.buffers = 1;
3435 gl_info->limits.textures = 0;
3436 gl_info->limits.texture_coords = 0;
3437 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
3439 gl_info->limits.uniform_blocks[i] = 0;
3440 gl_info->limits.samplers[i] = 0;
3442 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = 1;
3443 gl_info->limits.combined_samplers = gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL];
3444 gl_info->limits.graphics_samplers = gl_info->limits.combined_samplers;
3445 gl_info->limits.vertex_attribs = 16;
3446 gl_info->limits.texture_buffer_offset_alignment = 1;
3447 gl_info->limits.glsl_vs_float_constants = 0;
3448 gl_info->limits.glsl_ps_float_constants = 0;
3449 gl_info->limits.arb_vs_float_constants = 0;
3450 gl_info->limits.arb_vs_native_constants = 0;
3451 gl_info->limits.arb_vs_instructions = 0;
3452 gl_info->limits.arb_vs_temps = 0;
3453 gl_info->limits.arb_ps_float_constants = 0;
3454 gl_info->limits.arb_ps_local_constants = 0;
3455 gl_info->limits.arb_ps_instructions = 0;
3456 gl_info->limits.arb_ps_temps = 0;
3458 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_CLIP_DISTANCES, &gl_max);
3459 gl_info->limits.user_clip_distances = min(MAX_CLIP_DISTANCES, gl_max);
3460 TRACE("Clip plane support - max planes %d.\n", gl_max);
3462 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3464 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
3465 gl_info->limits.lights = gl_max;
3466 TRACE("Light support - max lights %d.\n", gl_max);
3469 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max);
3470 gl_info->limits.texture_size = gl_max;
3471 TRACE("Maximum texture size support - max texture size %d.\n", gl_max);
3473 gl_info->gl_ops.gl.p_glGetFloatv(gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]
3474 ? GL_ALIASED_POINT_SIZE_RANGE : GL_POINT_SIZE_RANGE, gl_floatv);
3475 gl_info->limits.pointsize_min = gl_floatv[0];
3476 gl_info->limits.pointsize_max = gl_floatv[1];
3477 TRACE("Maximum point size support - max point size %f.\n", gl_floatv[1]);
3479 if (gl_info->supported[ARB_MAP_BUFFER_ALIGNMENT])
3481 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &gl_max);
3482 TRACE("Minimum buffer map alignment: %d.\n", gl_max);
3484 else
3486 WARN_(d3d_perf)("Driver doesn't guarantee a minimum buffer map alignment.\n");
3488 if (gl_info->supported[NV_REGISTER_COMBINERS])
3490 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max);
3491 gl_info->limits.general_combiners = gl_max;
3492 TRACE("Max general combiners: %d.\n", gl_max);
3494 if (gl_info->supported[ARB_DRAW_BUFFERS] && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
3496 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max);
3497 gl_info->limits.buffers = gl_max;
3498 TRACE("Max draw buffers: %u.\n", gl_max);
3500 if (gl_info->supported[ARB_MULTITEXTURE])
3502 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3504 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
3505 gl_info->limits.textures = min(MAX_TEXTURES, gl_max);
3506 TRACE("Max textures: %d.\n", gl_info->limits.textures);
3508 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
3510 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &gl_max);
3511 gl_info->limits.texture_coords = min(MAX_TEXTURES, gl_max);
3513 else
3515 gl_info->limits.texture_coords = gl_info->limits.textures;
3517 TRACE("Max texture coords: %d.\n", gl_info->limits.texture_coords);
3520 if (gl_info->supported[ARB_FRAGMENT_PROGRAM] || gl_info->supported[ARB_FRAGMENT_SHADER])
3522 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &gl_max);
3523 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = gl_max;
3525 else
3527 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = gl_info->limits.textures;
3529 TRACE("Max fragment samplers: %d.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL]);
3531 if (gl_info->supported[ARB_VERTEX_SHADER])
3533 unsigned int vertex_sampler_count;
3535 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &gl_max);
3536 vertex_sampler_count = gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX] = gl_max;
3537 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &gl_max);
3538 gl_info->limits.combined_samplers = gl_max;
3539 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &gl_max);
3540 gl_info->limits.vertex_attribs = gl_max;
3542 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
3543 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
3544 * an issue because then the sampler setup only depends on the two shaders. If a pixel
3545 * shader is used with fixed function vertex processing we're fine too because fixed function
3546 * vertex processing doesn't use any samplers. If fixed function fragment processing is
3547 * used we have to make sure that all vertex sampler setups are valid together with all
3548 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
3549 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
3550 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
3551 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
3552 * a fixed function pipeline anymore.
3554 * So this is just a check to check that our assumption holds true. If not, write a warning
3555 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
3556 if (vertex_sampler_count && gl_info->limits.combined_samplers < 12
3557 && MAX_TEXTURES + vertex_sampler_count > gl_info->limits.combined_samplers)
3559 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
3560 vertex_sampler_count, gl_info->limits.combined_samplers);
3561 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
3562 if (gl_info->limits.combined_samplers > MAX_TEXTURES)
3563 vertex_sampler_count = gl_info->limits.combined_samplers - MAX_TEXTURES;
3564 else
3565 vertex_sampler_count = 0;
3566 gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX] = vertex_sampler_count;
3569 else
3571 gl_info->limits.combined_samplers = gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL];
3573 TRACE("Max vertex samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX]);
3574 TRACE("Max combined samplers: %u.\n", gl_info->limits.combined_samplers);
3575 TRACE("Max vertex attributes: %u.\n", gl_info->limits.vertex_attribs);
3577 else
3579 gl_info->limits.textures = 1;
3580 gl_info->limits.texture_coords = 1;
3583 if (gl_info->supported[ARB_VERTEX_BLEND])
3585 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
3586 gl_info->limits.blends = gl_max;
3587 TRACE("Max blends: %u.\n", gl_info->limits.blends);
3589 if (gl_info->supported[EXT_TEXTURE3D])
3591 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &gl_max);
3592 gl_info->limits.texture3d_size = gl_max;
3593 TRACE("Max texture3D size: %d.\n", gl_info->limits.texture3d_size);
3595 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
3597 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max);
3598 gl_info->limits.anisotropy = gl_max;
3599 TRACE("Max anisotropy: %d.\n", gl_info->limits.anisotropy);
3601 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
3603 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
3604 gl_info->limits.arb_ps_float_constants = gl_max;
3605 TRACE("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info->limits.arb_ps_float_constants);
3606 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
3607 gl_info->limits.arb_ps_native_constants = gl_max;
3608 TRACE("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
3609 gl_info->limits.arb_ps_native_constants);
3610 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
3611 gl_info->limits.arb_ps_temps = gl_max;
3612 TRACE("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_ps_temps);
3613 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
3614 gl_info->limits.arb_ps_instructions = gl_max;
3615 TRACE("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info->limits.arb_ps_instructions);
3616 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &gl_max));
3617 gl_info->limits.arb_ps_local_constants = gl_max;
3618 TRACE("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info->limits.arb_ps_instructions);
3620 if (gl_info->supported[ARB_VERTEX_PROGRAM])
3622 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
3623 gl_info->limits.arb_vs_float_constants = gl_max;
3624 TRACE("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info->limits.arb_vs_float_constants);
3625 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
3626 gl_info->limits.arb_vs_native_constants = gl_max;
3627 TRACE("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
3628 gl_info->limits.arb_vs_native_constants);
3629 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
3630 gl_info->limits.arb_vs_temps = gl_max;
3631 TRACE("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_vs_temps);
3632 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
3633 gl_info->limits.arb_vs_instructions = gl_max;
3634 TRACE("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info->limits.arb_vs_instructions);
3636 if (gl_info->supported[ARB_VERTEX_SHADER])
3638 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &gl_max);
3639 gl_info->limits.glsl_vs_float_constants = gl_max / 4;
3640 TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info->limits.glsl_vs_float_constants);
3642 if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3644 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &gl_max);
3645 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_VERTEX] = min(gl_max, WINED3D_MAX_CBS);
3646 TRACE("Max vertex uniform blocks: %u (%d).\n",
3647 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_VERTEX], gl_max);
3650 if (gl_info->supported[ARB_TESSELLATION_SHADER])
3652 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS, &gl_max);
3653 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_HULL] = min(gl_max, WINED3D_MAX_CBS);
3654 TRACE("Max hull uniform blocks: %u (%d).\n",
3655 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_HULL], gl_max);
3656 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS, &gl_max);
3657 gl_info->limits.samplers[WINED3D_SHADER_TYPE_HULL] = gl_max;
3658 TRACE("Max hull samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_HULL]);
3660 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS, &gl_max);
3661 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_DOMAIN] = min(gl_max, WINED3D_MAX_CBS);
3662 TRACE("Max domain uniform blocks: %u (%d).\n",
3663 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_DOMAIN], gl_max);
3664 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS, &gl_max);
3665 gl_info->limits.samplers[WINED3D_SHADER_TYPE_DOMAIN] = gl_max;
3666 TRACE("Max domain samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_DOMAIN]);
3668 if (gl_info->supported[WINED3D_GL_VERSION_3_2] && gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3670 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GEOMETRY_UNIFORM_BLOCKS, &gl_max);
3671 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_GEOMETRY] = min(gl_max, WINED3D_MAX_CBS);
3672 TRACE("Max geometry uniform blocks: %u (%d).\n",
3673 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_GEOMETRY], gl_max);
3674 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, &gl_max);
3675 gl_info->limits.samplers[WINED3D_SHADER_TYPE_GEOMETRY] = gl_max;
3676 TRACE("Max geometry samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_GEOMETRY]);
3678 if (gl_info->supported[ARB_FRAGMENT_SHADER])
3680 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &gl_max);
3681 gl_info->limits.glsl_ps_float_constants = gl_max / 4;
3682 TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info->limits.glsl_ps_float_constants);
3683 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
3684 gl_info->limits.glsl_varyings = gl_max;
3685 TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
3687 if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3689 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &gl_max);
3690 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_PIXEL] = min(gl_max, WINED3D_MAX_CBS);
3691 TRACE("Max fragment uniform blocks: %u (%d).\n",
3692 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_PIXEL], gl_max);
3695 if (gl_info->supported[ARB_COMPUTE_SHADER])
3697 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMPUTE_UNIFORM_BLOCKS, &gl_max);
3698 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_COMPUTE] = min(gl_max, WINED3D_MAX_CBS);
3699 TRACE("Max compute uniform blocks: %u (%d).\n",
3700 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_COMPUTE], gl_max);
3701 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS, &gl_max);
3702 gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE] = gl_max;
3703 TRACE("Max compute samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE]);
3705 if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3707 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &gl_max);
3708 TRACE("Max combined uniform blocks: %d.\n", gl_max);
3709 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &gl_max);
3710 TRACE("Max uniform buffer bindings: %d.\n", gl_max);
3712 if (gl_info->supported[ARB_TEXTURE_BUFFER_RANGE])
3714 gl_info->gl_ops.gl.p_glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &gl_max);
3715 gl_info->limits.texture_buffer_offset_alignment = gl_max;
3716 TRACE("Minimum required texture buffer offset alignment %d.\n", gl_max);
3718 if (gl_info->supported[ARB_SHADER_ATOMIC_COUNTERS])
3720 GLint max_fragment_buffers, max_combined_buffers, max_bindings;
3721 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS, &max_fragment_buffers);
3722 TRACE("Max fragment atomic counter buffers: %d.\n", max_fragment_buffers);
3723 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS, &max_combined_buffers);
3724 TRACE("Max combined atomic counter buffers: %d.\n", max_combined_buffers);
3725 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &max_bindings);
3726 TRACE("Max atomic counter buffer bindings: %d.\n", max_bindings);
3727 if (max_fragment_buffers < MAX_UNORDERED_ACCESS_VIEWS
3728 || max_combined_buffers < MAX_UNORDERED_ACCESS_VIEWS
3729 || max_bindings < MAX_UNORDERED_ACCESS_VIEWS)
3731 WARN("Disabling ARB_shader_atomic_counters.\n");
3732 gl_info->supported[ARB_SHADER_ATOMIC_COUNTERS] = FALSE;
3735 if (gl_info->supported[ARB_TRANSFORM_FEEDBACK3])
3737 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_STREAMS, &gl_max);
3738 TRACE("Max vertex streams: %d.\n", gl_max);
3741 if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
3742 gl_info->gl_ops.gl.p_glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess);
3743 else
3744 gl_info->limits.shininess = 128.0f;
3746 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT] || gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
3748 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_SAMPLES, &gl_max);
3749 gl_info->limits.samples = gl_max;
3752 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] =
3753 min(gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL], MAX_GL_FRAGMENT_SAMPLERS);
3754 sampler_count = 0;
3755 for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
3756 sampler_count += gl_info->limits.samplers[i];
3757 if (gl_info->supported[WINED3D_GL_VERSION_3_2] && gl_info->limits.combined_samplers < sampler_count)
3759 /* The minimum value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS in OpenGL
3760 * 3.2 is 48 (16 per stage). When tessellation shaders are supported
3761 * the minimum value is increased to 80. */
3762 WARN("Graphics pipeline sampler count %u is greater than combined sampler count %u.\n",
3763 sampler_count, gl_info->limits.combined_samplers);
3764 for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
3765 gl_info->limits.samplers[i] = min(gl_info->limits.samplers[i], 16);
3768 /* A majority of OpenGL implementations allow us to statically partition
3769 * the set of texture bindings into six separate sets. */
3770 gl_info->limits.graphics_samplers = gl_info->limits.combined_samplers;
3771 sampler_count = 0;
3772 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
3773 sampler_count += gl_info->limits.samplers[i];
3774 if (gl_info->limits.combined_samplers >= sampler_count)
3775 gl_info->limits.graphics_samplers -= gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE];
3778 /* Context activation is done by the caller. */
3779 static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
3780 struct wined3d_caps_gl_ctx *caps_gl_ctx, DWORD wined3d_creation_flags)
3782 static const struct
3784 enum wined3d_gl_extension extension;
3785 DWORD min_gl_version;
3787 core_extensions[] =
3789 {EXT_TEXTURE3D, MAKEDWORD_VERSION(1, 2)},
3790 {ARB_MULTISAMPLE, MAKEDWORD_VERSION(1, 3)},
3791 {ARB_MULTITEXTURE, MAKEDWORD_VERSION(1, 3)},
3792 {ARB_TEXTURE_BORDER_CLAMP, MAKEDWORD_VERSION(1, 3)},
3793 {ARB_TEXTURE_COMPRESSION, MAKEDWORD_VERSION(1, 3)},
3794 {ARB_TEXTURE_CUBE_MAP, MAKEDWORD_VERSION(1, 3)},
3795 {ARB_DEPTH_TEXTURE, MAKEDWORD_VERSION(1, 4)},
3796 {ARB_POINT_PARAMETERS, MAKEDWORD_VERSION(1, 4)},
3797 {ARB_SHADOW, MAKEDWORD_VERSION(1, 4)},
3798 {ARB_TEXTURE_MIRRORED_REPEAT, MAKEDWORD_VERSION(1, 4)},
3799 {EXT_BLEND_COLOR, MAKEDWORD_VERSION(1, 4)},
3800 {EXT_BLEND_FUNC_SEPARATE, MAKEDWORD_VERSION(1, 4)},
3801 {EXT_BLEND_MINMAX, MAKEDWORD_VERSION(1, 4)},
3802 {EXT_BLEND_SUBTRACT, MAKEDWORD_VERSION(1, 4)},
3803 {EXT_STENCIL_WRAP, MAKEDWORD_VERSION(1, 4)},
3804 {NV_POINT_SPRITE, MAKEDWORD_VERSION(1, 4)},
3805 {ARB_OCCLUSION_QUERY, MAKEDWORD_VERSION(1, 5)},
3806 {ARB_VERTEX_BUFFER_OBJECT, MAKEDWORD_VERSION(1, 5)},
3807 {ARB_DRAW_BUFFERS, MAKEDWORD_VERSION(2, 0)},
3808 {ARB_FRAGMENT_SHADER, MAKEDWORD_VERSION(2, 0)},
3809 {ARB_SHADING_LANGUAGE_100, MAKEDWORD_VERSION(2, 0)},
3810 {ARB_TEXTURE_NON_POWER_OF_TWO, MAKEDWORD_VERSION(2, 0)},
3811 {ARB_VERTEX_SHADER, MAKEDWORD_VERSION(2, 0)},
3812 {EXT_BLEND_EQUATION_SEPARATE, MAKEDWORD_VERSION(2, 0)},
3813 {ARB_PIXEL_BUFFER_OBJECT, MAKEDWORD_VERSION(2, 1)},
3814 {EXT_TEXTURE_SRGB, MAKEDWORD_VERSION(2, 1)},
3815 {ARB_COLOR_BUFFER_FLOAT, MAKEDWORD_VERSION(3, 0)},
3816 {ARB_DEPTH_BUFFER_FLOAT, MAKEDWORD_VERSION(3, 0)},
3817 {ARB_FRAMEBUFFER_OBJECT, MAKEDWORD_VERSION(3, 0)},
3818 {ARB_FRAMEBUFFER_SRGB, MAKEDWORD_VERSION(3, 0)},
3819 {ARB_HALF_FLOAT_PIXEL, MAKEDWORD_VERSION(3, 0)},
3820 {ARB_HALF_FLOAT_VERTEX, MAKEDWORD_VERSION(3, 0)},
3821 {ARB_MAP_BUFFER_RANGE, MAKEDWORD_VERSION(3, 0)},
3822 {ARB_TEXTURE_COMPRESSION_RGTC, MAKEDWORD_VERSION(3, 0)},
3823 {ARB_TEXTURE_FLOAT, MAKEDWORD_VERSION(3, 0)},
3824 {ARB_TEXTURE_RG, MAKEDWORD_VERSION(3, 0)},
3825 {EXT_DRAW_BUFFERS2, MAKEDWORD_VERSION(3, 0)},
3826 {EXT_PACKED_FLOAT, MAKEDWORD_VERSION(3, 0)},
3827 {EXT_TEXTURE_ARRAY, MAKEDWORD_VERSION(3, 0)},
3828 {EXT_TEXTURE_INTEGER, MAKEDWORD_VERSION(3, 0)},
3829 {EXT_TEXTURE_SHARED_EXPONENT, MAKEDWORD_VERSION(3, 0)},
3830 /* We don't want to enable EXT_GPU_SHADER4: even though similar
3831 * functionality is available in core GL 3.0 / GLSL 1.30, it's different
3832 * enough that reusing the same flag for the new features hurts more
3833 * than it helps. */
3834 /* EXT_framebuffer_object, EXT_framebuffer_blit,
3835 * EXT_framebuffer_multisample and EXT_packed_depth_stencil
3836 * are integrated into ARB_framebuffer_object. */
3838 {ARB_COPY_BUFFER, MAKEDWORD_VERSION(3, 1)},
3839 {ARB_DRAW_INSTANCED, MAKEDWORD_VERSION(3, 1)},
3840 {ARB_TEXTURE_BUFFER_OBJECT, MAKEDWORD_VERSION(3, 1)},
3841 {ARB_UNIFORM_BUFFER_OBJECT, MAKEDWORD_VERSION(3, 1)},
3842 {EXT_TEXTURE_SNORM, MAKEDWORD_VERSION(3, 1)},
3843 /* We don't need or want GL_ARB_texture_rectangle (core in 3.1). */
3845 {ARB_DRAW_ELEMENTS_BASE_VERTEX, MAKEDWORD_VERSION(3, 2)},
3846 /* ARB_geometry_shader4 exposes a somewhat different API compared to 3.2
3847 * core geometry shaders so it's not really correct to expose the
3848 * extension for core-only support. */
3849 {ARB_FRAGMENT_COORD_CONVENTIONS, MAKEDWORD_VERSION(3, 2)},
3850 {ARB_PROVOKING_VERTEX, MAKEDWORD_VERSION(3, 2)},
3851 {ARB_SEAMLESS_CUBE_MAP, MAKEDWORD_VERSION(3, 2)},
3852 {ARB_SYNC, MAKEDWORD_VERSION(3, 2)},
3853 {ARB_VERTEX_ARRAY_BGRA, MAKEDWORD_VERSION(3, 2)},
3855 {ARB_BLEND_FUNC_EXTENDED, MAKEDWORD_VERSION(3, 3)},
3856 {ARB_EXPLICIT_ATTRIB_LOCATION, MAKEDWORD_VERSION(3, 3)},
3857 {ARB_INSTANCED_ARRAYS, MAKEDWORD_VERSION(3, 3)},
3858 {ARB_SAMPLER_OBJECTS, MAKEDWORD_VERSION(3, 3)},
3859 {ARB_SHADER_BIT_ENCODING, MAKEDWORD_VERSION(3, 3)},
3860 {ARB_TEXTURE_RGB10_A2UI, MAKEDWORD_VERSION(3, 3)},
3861 {ARB_TEXTURE_SWIZZLE, MAKEDWORD_VERSION(3, 3)},
3862 {ARB_TIMER_QUERY, MAKEDWORD_VERSION(3, 3)},
3863 {ARB_VERTEX_TYPE_2_10_10_10_REV, MAKEDWORD_VERSION(3, 3)},
3865 {ARB_GPU_SHADER5, MAKEDWORD_VERSION(4, 0)},
3866 {ARB_TESSELLATION_SHADER, MAKEDWORD_VERSION(4, 0)},
3867 {ARB_TEXTURE_CUBE_MAP_ARRAY, MAKEDWORD_VERSION(4, 0)},
3868 {ARB_TEXTURE_GATHER, MAKEDWORD_VERSION(4, 0)},
3869 {ARB_TRANSFORM_FEEDBACK2, MAKEDWORD_VERSION(4, 0)},
3870 {ARB_TRANSFORM_FEEDBACK3, MAKEDWORD_VERSION(4, 0)},
3872 {ARB_ES2_COMPATIBILITY, MAKEDWORD_VERSION(4, 1)},
3873 {ARB_VIEWPORT_ARRAY, MAKEDWORD_VERSION(4, 1)},
3875 {ARB_INTERNALFORMAT_QUERY, MAKEDWORD_VERSION(4, 2)},
3876 {ARB_MAP_BUFFER_ALIGNMENT, MAKEDWORD_VERSION(4, 2)},
3877 {ARB_SHADER_ATOMIC_COUNTERS, MAKEDWORD_VERSION(4, 2)},
3878 {ARB_SHADER_IMAGE_LOAD_STORE, MAKEDWORD_VERSION(4, 2)},
3879 {ARB_SHADING_LANGUAGE_420PACK, MAKEDWORD_VERSION(4, 2)},
3880 {ARB_SHADING_LANGUAGE_PACKING, MAKEDWORD_VERSION(4, 2)},
3881 {ARB_TEXTURE_COMPRESSION_BPTC, MAKEDWORD_VERSION(4, 2)},
3882 {ARB_TEXTURE_STORAGE, MAKEDWORD_VERSION(4, 2)},
3884 {ARB_CLEAR_BUFFER_OBJECT, MAKEDWORD_VERSION(4, 3)},
3885 {ARB_COMPUTE_SHADER, MAKEDWORD_VERSION(4, 3)},
3886 {ARB_DEBUG_OUTPUT, MAKEDWORD_VERSION(4, 3)},
3887 {ARB_ES3_COMPATIBILITY, MAKEDWORD_VERSION(4, 3)},
3888 {ARB_FRAGMENT_LAYER_VIEWPORT, MAKEDWORD_VERSION(4, 3)},
3889 {ARB_INTERNALFORMAT_QUERY2, MAKEDWORD_VERSION(4, 3)},
3890 {ARB_SHADER_IMAGE_SIZE, MAKEDWORD_VERSION(4, 3)},
3891 {ARB_SHADER_STORAGE_BUFFER_OBJECT, MAKEDWORD_VERSION(4, 3)},
3892 {ARB_STENCIL_TEXTURING, MAKEDWORD_VERSION(4, 3)},
3893 {ARB_TEXTURE_BUFFER_RANGE, MAKEDWORD_VERSION(4, 3)},
3894 {ARB_TEXTURE_QUERY_LEVELS, MAKEDWORD_VERSION(4, 3)},
3895 {ARB_TEXTURE_VIEW, MAKEDWORD_VERSION(4, 3)},
3897 {ARB_CLEAR_TEXTURE, MAKEDWORD_VERSION(4, 4)},
3899 {ARB_CLIP_CONTROL, MAKEDWORD_VERSION(4, 5)},
3900 {ARB_DERIVATIVE_CONTROL, MAKEDWORD_VERSION(4, 5)},
3902 struct wined3d_driver_info *driver_info = &adapter->driver_info;
3903 const char *gl_vendor_str, *gl_renderer_str, *gl_version_str;
3904 struct wined3d_gl_info *gl_info = &adapter->gl_info;
3905 const struct gpu_description *gpu_description;
3906 struct wined3d_vertex_caps vertex_caps;
3907 struct fragment_caps fragment_caps;
3908 struct shader_caps shader_caps;
3909 const char *WGL_Extensions = NULL;
3910 enum wined3d_gl_vendor gl_vendor;
3911 DWORD gl_version, gl_ext_emul_mask;
3912 UINT64 vram_bytes = 0;
3913 HDC hdc;
3914 unsigned int i, j;
3915 GLint context_profile = 0;
3917 TRACE("adapter %p.\n", adapter);
3919 gl_renderer_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER);
3920 TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str));
3921 if (!gl_renderer_str)
3923 ERR("Received a NULL GL_RENDERER.\n");
3924 return FALSE;
3927 gl_vendor_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VENDOR);
3928 TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str));
3929 if (!gl_vendor_str)
3931 ERR("Received a NULL GL_VENDOR.\n");
3932 return FALSE;
3935 /* Parse the GL_VERSION field into major and minor information */
3936 gl_version_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VERSION);
3937 TRACE("GL_VERSION: %s.\n", debugstr_a(gl_version_str));
3938 if (!gl_version_str)
3940 ERR("Received a NULL GL_VERSION.\n");
3941 return FALSE;
3943 gl_version = wined3d_parse_gl_version(gl_version_str);
3945 load_gl_funcs(gl_info);
3947 memset(gl_info->supported, 0, sizeof(gl_info->supported));
3948 gl_info->supported[WINED3D_GL_EXT_NONE] = TRUE;
3950 if (gl_version >= MAKEDWORD_VERSION(3, 2))
3952 gl_info->gl_ops.gl.p_glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &context_profile);
3953 checkGLcall("Querying context profile");
3955 if (context_profile & GL_CONTEXT_CORE_PROFILE_BIT)
3956 TRACE("Got a core profile context.\n");
3957 else
3958 gl_info->supported[WINED3D_GL_LEGACY_CONTEXT] = TRUE;
3960 TRACE("GL extensions reported:\n");
3961 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3963 const char *gl_extensions = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_EXTENSIONS);
3965 if (!gl_extensions)
3967 ERR("Received a NULL GL_EXTENSIONS.\n");
3968 return FALSE;
3970 parse_extension_string(gl_info, gl_extensions, gl_extension_map,
3971 sizeof(gl_extension_map) / sizeof(*gl_extension_map));
3973 else
3975 enumerate_gl_extensions(gl_info, gl_extension_map,
3976 sizeof(gl_extension_map) / sizeof(*gl_extension_map));
3979 hdc = wglGetCurrentDC();
3980 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
3981 if (GL_EXTCALL(wglGetExtensionsStringARB))
3982 WGL_Extensions = (const char *)GL_EXTCALL(wglGetExtensionsStringARB(hdc));
3983 if (!WGL_Extensions)
3984 WARN("WGL extensions not supported.\n");
3985 else
3986 parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map,
3987 sizeof(wgl_extension_map) / sizeof(*wgl_extension_map));
3989 for (i = 0; i < ARRAY_SIZE(core_extensions); ++i)
3991 if (!gl_info->supported[core_extensions[i].extension]
3992 && gl_version >= core_extensions[i].min_gl_version)
3994 for (j = 0; j < ARRAY_SIZE(gl_extension_map); ++j)
3995 if (gl_extension_map[j].extension == core_extensions[i].extension)
3996 break;
3998 if (j < ARRAY_SIZE(gl_extension_map))
4000 TRACE("GL CORE: %s support.\n", gl_extension_map[j].extension_string);
4001 gl_info->supported[core_extensions[i].extension] = TRUE;
4003 else
4005 FIXME("GL extension %u not in the GL extensions map.\n", core_extensions[i].extension);
4010 if (gl_info->supported[EXT_BLEND_MINMAX] || gl_info->supported[EXT_BLEND_SUBTRACT])
4011 gl_info->supported[WINED3D_GL_BLEND_EQUATION] = TRUE;
4013 if (gl_version >= MAKEDWORD_VERSION(2, 0))
4014 gl_info->supported[WINED3D_GL_VERSION_2_0] = TRUE;
4015 if (gl_version >= MAKEDWORD_VERSION(3, 2))
4016 gl_info->supported[WINED3D_GL_VERSION_3_2] = TRUE;
4018 /* All the points are actually point sprites in core contexts, the APIs from
4019 * ARB_point_sprite are not supported anymore. */
4020 if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
4021 gl_info->supported[ARB_POINT_SPRITE] = FALSE;
4023 if (gl_info->supported[APPLE_FENCE])
4025 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
4026 * The apple extension interacts with some other apple exts. Disable the NV
4027 * extension if the apple one is support to prevent confusion in other parts
4028 * of the code. */
4029 gl_info->supported[NV_FENCE] = FALSE;
4031 if (gl_info->supported[APPLE_FLOAT_PIXELS])
4033 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
4035 * The enums are the same:
4036 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881a
4037 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881b
4038 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
4039 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
4040 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140b
4042 if (!gl_info->supported[ARB_TEXTURE_FLOAT])
4044 TRACE(" IMPLIED: GL_ARB_texture_float support (by GL_APPLE_float_pixels).\n");
4045 gl_info->supported[ARB_TEXTURE_FLOAT] = TRUE;
4047 if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
4049 TRACE(" IMPLIED: GL_ARB_half_float_pixel support (by GL_APPLE_float_pixels).\n");
4050 gl_info->supported[ARB_HALF_FLOAT_PIXEL] = TRUE;
4053 if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
4055 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
4056 * functionality. Prefer the ARB extension */
4057 gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] = FALSE;
4059 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
4061 TRACE(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
4062 gl_info->supported[NV_TEXGEN_REFLECTION] = TRUE;
4064 if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
4066 TRACE(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
4067 gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE;
4069 if (!gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC] && gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC])
4071 TRACE(" IMPLIED: EXT_texture_compression_rgtc support (by ARB_texture_compression_rgtc).\n");
4072 gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC] = TRUE;
4074 if (!gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] && gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
4076 TRACE(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
4077 gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] = TRUE;
4079 if (gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] && !gl_info->supported[ARB_TEXTURE_RG])
4081 TRACE("ARB_texture_rg not supported, disabling ARB_texture_compression_rgtc.\n");
4082 gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] = FALSE;
4084 if (gl_info->supported[NV_TEXTURE_SHADER2])
4086 if (gl_info->supported[NV_REGISTER_COMBINERS])
4088 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
4089 * are supported. The nv extensions provide the same functionality as the
4090 * ATI one, and a bit more(signed pixelformats). */
4091 gl_info->supported[ATI_FRAGMENT_SHADER] = FALSE;
4094 if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
4096 /* If we have full NP2 texture support, disable
4097 * GL_ARB_texture_rectangle because we will never use it.
4098 * This saves a few redundant glDisable calls. */
4099 gl_info->supported[ARB_TEXTURE_RECTANGLE] = FALSE;
4101 if (gl_info->supported[ATI_FRAGMENT_SHADER])
4103 /* Disable NV_register_combiners and fragment shader if this is supported.
4104 * generally the NV extensions are preferred over the ATI ones, and this
4105 * extension is disabled if register_combiners and texture_shader2 are both
4106 * supported. So we reach this place only if we have incomplete NV dxlevel 8
4107 * fragment processing support. */
4108 gl_info->supported[NV_REGISTER_COMBINERS] = FALSE;
4109 gl_info->supported[NV_REGISTER_COMBINERS2] = FALSE;
4110 gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
4111 gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
4113 if (gl_info->supported[NV_HALF_FLOAT])
4115 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
4116 gl_info->supported[ARB_HALF_FLOAT_VERTEX] = TRUE;
4118 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB] && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
4120 /* Current wined3d sRGB infrastructure requires EXT_texture_sRGB_decode
4121 * for GL_ARB_framebuffer_sRGB support (without EXT_texture_sRGB_decode
4122 * we never render to sRGB surfaces). */
4123 TRACE("EXT_texture_sRGB_decode is not supported, disabling ARB_framebuffer_sRGB.\n");
4124 gl_info->supported[ARB_FRAMEBUFFER_SRGB] = FALSE;
4126 if (gl_info->supported[ARB_OCCLUSION_QUERY])
4128 GLint counter_bits;
4130 GL_EXTCALL(glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, &counter_bits));
4131 TRACE("Occlusion query counter has %d bits.\n", counter_bits);
4132 if (!counter_bits)
4133 gl_info->supported[ARB_OCCLUSION_QUERY] = FALSE;
4135 if (gl_info->supported[ARB_TIMER_QUERY])
4137 GLint counter_bits;
4139 GL_EXTCALL(glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, &counter_bits));
4140 TRACE("Timestamp query counter has %d bits.\n", counter_bits);
4141 if (!counter_bits)
4142 gl_info->supported[ARB_TIMER_QUERY] = FALSE;
4144 if (gl_version >= MAKEDWORD_VERSION(3, 0))
4146 GLint counter_bits;
4148 gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY] = TRUE;
4150 GL_EXTCALL(glGetQueryiv(GL_PRIMITIVES_GENERATED, GL_QUERY_COUNTER_BITS, &counter_bits));
4151 TRACE("Primitives query counter has %d bits.\n", counter_bits);
4152 if (!counter_bits)
4153 gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY] = FALSE;
4155 GL_EXTCALL(glGetQueryiv(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, GL_QUERY_COUNTER_BITS, &counter_bits));
4156 TRACE("Transform feedback primitives query counter has %d bits.\n", counter_bits);
4157 if (!counter_bits)
4158 gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY] = FALSE;
4160 if (gl_info->supported[ARB_VIEWPORT_ARRAY])
4162 GLint subpixel_bits;
4164 gl_info->gl_ops.gl.p_glGetIntegerv(GL_VIEWPORT_SUBPIXEL_BITS, &subpixel_bits);
4165 TRACE("Viewport supports %d subpixel bits.\n", subpixel_bits);
4166 if (subpixel_bits < 8 && gl_info->supported[ARB_CLIP_CONTROL])
4168 TRACE("Disabling ARB_clip_control because viewport subpixel bits < 8.\n");
4169 gl_info->supported[ARB_CLIP_CONTROL] = FALSE;
4172 if (gl_info->supported[ARB_CLIP_CONTROL] && !gl_info->supported[ARB_VIEWPORT_ARRAY])
4174 /* When using ARB_clip_control we need the float viewport parameters
4175 * introduced by ARB_viewport_array to take care of the shifted pixel
4176 * coordinates. */
4177 TRACE("Disabling ARB_clip_control because ARB_viewport_array is not supported.\n");
4178 gl_info->supported[ARB_CLIP_CONTROL] = FALSE;
4180 if (gl_info->supported[ARB_STENCIL_TEXTURING] && !gl_info->supported[ARB_TEXTURE_SWIZZLE])
4182 /* The stencil value needs to be placed in the green channel. */
4183 TRACE("Disabling ARB_stencil_texturing because ARB_texture_swizzle is not supported.\n");
4184 gl_info->supported[ARB_STENCIL_TEXTURING] = FALSE;
4186 if (!gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] && gl_info->supported[EXT_TEXTURE_MIRROR_CLAMP])
4188 TRACE(" IMPLIED: ATI_texture_mirror_once support (by EXT_texture_mirror_clamp).\n");
4189 gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] = TRUE;
4191 if (!gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] && gl_info->supported[ATI_TEXTURE_MIRROR_ONCE])
4193 TRACE(" IMPLIED: ARB_texture_mirror_clamp_to_edge support (by ATI_texture_mirror_once).\n");
4194 gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] = TRUE;
4196 if (gl_info->supported[ARB_TEXTURE_STORAGE] && gl_info->supported[APPLE_YCBCR_422])
4198 /* AFAIK APPLE_ycbcr_422 is only available in legacy contexts so we shouldn't ever hit this. */
4199 FIXME("Disabling APPLE_ycbcr_422 because of ARB_texture_storage.\n");
4200 gl_info->supported[APPLE_YCBCR_422] = FALSE;
4203 wined3d_adapter_init_limits(gl_info);
4205 if (gl_info->supported[ARB_VERTEX_PROGRAM] && test_arb_vs_offset_limit(gl_info))
4206 gl_info->quirks |= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT;
4208 if (gl_info->supported[ARB_SHADING_LANGUAGE_100])
4210 const char *str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
4211 unsigned int major, minor;
4213 TRACE("GLSL version string: %s.\n", debugstr_a(str));
4215 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
4216 sscanf(str, "%u.%u", &major, &minor);
4217 gl_info->glsl_version = MAKEDWORD_VERSION(major, minor);
4218 if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 30))
4219 gl_info->supported[WINED3D_GLSL_130] = TRUE;
4222 checkGLcall("extension detection");
4224 adapter->shader_backend = select_shader_backend(gl_info);
4225 adapter->vertex_pipe = select_vertex_implementation(gl_info, adapter->shader_backend);
4226 adapter->fragment_pipe = select_fragment_implementation(gl_info, adapter->shader_backend);
4228 adapter->shader_backend->shader_get_caps(gl_info, &shader_caps);
4229 adapter->d3d_info.vs_clipping = shader_caps.wined3d_caps & WINED3D_SHADER_CAP_VS_CLIPPING;
4230 adapter->d3d_info.limits.vs_version = shader_caps.vs_version;
4231 adapter->d3d_info.limits.hs_version = shader_caps.hs_version;
4232 adapter->d3d_info.limits.ds_version = shader_caps.ds_version;
4233 adapter->d3d_info.limits.gs_version = shader_caps.gs_version;
4234 adapter->d3d_info.limits.ps_version = shader_caps.ps_version;
4235 adapter->d3d_info.limits.cs_version = shader_caps.cs_version;
4236 adapter->d3d_info.limits.vs_uniform_count = shader_caps.vs_uniform_count;
4237 adapter->d3d_info.limits.ps_uniform_count = shader_caps.ps_uniform_count;
4238 adapter->d3d_info.limits.varying_count = shader_caps.varying_count;
4239 adapter->d3d_info.shader_double_precision = shader_caps.wined3d_caps & WINED3D_SHADER_CAP_DOUBLE_PRECISION;
4241 adapter->vertex_pipe->vp_get_caps(gl_info, &vertex_caps);
4242 adapter->d3d_info.xyzrhw = vertex_caps.xyzrhw;
4243 adapter->d3d_info.ffp_generic_attributes = vertex_caps.ffp_generic_attributes;
4244 adapter->d3d_info.limits.ffp_vertex_blend_matrices = vertex_caps.max_vertex_blend_matrices;
4245 adapter->d3d_info.limits.active_light_count = vertex_caps.max_active_lights;
4246 adapter->d3d_info.emulated_flatshading = vertex_caps.emulated_flatshading;
4248 adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
4249 adapter->d3d_info.limits.ffp_blend_stages = fragment_caps.MaxTextureBlendStages;
4250 adapter->d3d_info.limits.ffp_textures = fragment_caps.MaxSimultaneousTextures;
4251 adapter->d3d_info.shader_color_key = fragment_caps.wined3d_caps & WINED3D_FRAGMENT_CAP_COLOR_KEY;
4252 adapter->d3d_info.wined3d_creation_flags = wined3d_creation_flags;
4253 TRACE("Max texture stages: %u.\n", adapter->d3d_info.limits.ffp_blend_stages);
4255 adapter->d3d_info.valid_rt_mask = 0;
4256 for (i = 0; i < gl_info->limits.buffers; ++i)
4257 adapter->d3d_info.valid_rt_mask |= (1u << i);
4259 if (!adapter->d3d_info.shader_color_key)
4261 /* We do not want to deal with re-creating immutable texture storage for color keying emulation. */
4262 WARN("Disabling ARB_texture_storage because fragment pipe doesn't support color keying.\n");
4263 gl_info->supported[ARB_TEXTURE_STORAGE] = FALSE;
4266 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
4268 gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbuffer;
4269 gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbuffer;
4270 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffers;
4271 gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffers;
4272 gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorage;
4273 gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisample;
4274 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameteriv;
4275 gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebuffer;
4276 gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebuffer;
4277 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffers;
4278 gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffers;
4279 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatus;
4280 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1D;
4281 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2D;
4282 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3D;
4283 gl_info->fbo_ops.glFramebufferTextureLayer = gl_info->gl_ops.ext.p_glFramebufferTextureLayer;
4284 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbuffer;
4285 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
4286 = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameteriv;
4287 gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebuffer;
4288 gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmap;
4289 gl_info->fbo_ops.glFramebufferTexture = gl_info->gl_ops.ext.p_glFramebufferTexture;
4291 else
4293 if (gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
4295 gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbufferEXT;
4296 gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbufferEXT;
4297 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffersEXT;
4298 gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffersEXT;
4299 gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorageEXT;
4300 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameterivEXT;
4301 gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebufferEXT;
4302 gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebufferEXT;
4303 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffersEXT;
4304 gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffersEXT;
4305 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatusEXT;
4306 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1DEXT;
4307 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2DEXT;
4308 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3DEXT;
4309 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbufferEXT;
4310 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
4311 = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameterivEXT;
4312 gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmapEXT;
4314 else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
4316 WARN_(d3d_perf)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
4317 wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
4320 if (gl_info->supported[ARB_GEOMETRY_SHADER4])
4322 gl_info->fbo_ops.glFramebufferTexture = gl_info->gl_ops.ext.p_glFramebufferTextureARB;
4323 gl_info->fbo_ops.glFramebufferTextureLayer = gl_info->gl_ops.ext.p_glFramebufferTextureLayerARB;
4325 if (gl_info->supported[EXT_FRAMEBUFFER_BLIT])
4327 gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebufferEXT;
4329 if (gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
4331 gl_info->fbo_ops.glRenderbufferStorageMultisample
4332 = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisampleEXT;
4336 gl_info->wrap_lookup[WINED3D_TADDRESS_WRAP - WINED3D_TADDRESS_WRAP] = GL_REPEAT;
4337 gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR - WINED3D_TADDRESS_WRAP] =
4338 gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
4339 gl_info->wrap_lookup[WINED3D_TADDRESS_CLAMP - WINED3D_TADDRESS_WRAP] = GL_CLAMP_TO_EDGE;
4340 gl_info->wrap_lookup[WINED3D_TADDRESS_BORDER - WINED3D_TADDRESS_WRAP] =
4341 gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
4342 gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP] =
4343 gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] ? GL_MIRROR_CLAMP_TO_EDGE : GL_REPEAT;
4345 if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
4347 GLuint vao;
4349 GL_EXTCALL(glGenVertexArrays(1, &vao));
4350 GL_EXTCALL(glBindVertexArray(vao));
4351 checkGLcall("creating VAO");
4354 gl_vendor = wined3d_guess_gl_vendor(gl_info, gl_vendor_str, gl_renderer_str, gl_version_str);
4355 TRACE("Guessed GL vendor %#x.\n", gl_vendor);
4357 if (!(gpu_description = query_gpu_description(gl_info, &vram_bytes)))
4359 enum wined3d_pci_vendor vendor;
4360 enum wined3d_pci_device device;
4362 vendor = wined3d_guess_card_vendor(gl_vendor_str, gl_renderer_str);
4363 TRACE("Guessed vendor PCI ID 0x%04x.\n", vendor);
4365 device = wined3d_guess_card(&shader_caps, &fragment_caps, gl_info->glsl_version,
4366 gl_renderer_str, &gl_vendor, &vendor);
4367 TRACE("Guessed device PCI ID 0x%04x.\n", device);
4369 if (!(gpu_description = get_gpu_description(vendor, device)))
4371 ERR("Card %04x:%04x not found in driver DB.\n", vendor, device);
4372 return FALSE;
4375 fixup_extensions(gl_info, caps_gl_ctx, gl_renderer_str, gl_vendor,
4376 gpu_description->vendor, gpu_description->card);
4377 init_driver_info(driver_info, gpu_description, vram_bytes);
4379 gl_ext_emul_mask = adapter->vertex_pipe->vp_get_emul_mask(gl_info)
4380 | adapter->fragment_pipe->get_emul_mask(gl_info);
4381 if (gl_ext_emul_mask & GL_EXT_EMUL_ARB_MULTITEXTURE)
4382 install_gl_compat_wrapper(gl_info, ARB_MULTITEXTURE);
4383 if (gl_ext_emul_mask & GL_EXT_EMUL_EXT_FOG_COORD)
4384 install_gl_compat_wrapper(gl_info, EXT_FOG_COORD);
4386 return TRUE;
4389 UINT CDECL wined3d_get_adapter_count(const struct wined3d *wined3d)
4391 TRACE("wined3d %p, reporting %u adapters.\n",
4392 wined3d, wined3d->adapter_count);
4394 return wined3d->adapter_count;
4397 HRESULT CDECL wined3d_register_software_device(struct wined3d *wined3d, void *init_function)
4399 FIXME("wined3d %p, init_function %p stub!\n", wined3d, init_function);
4401 return WINED3D_OK;
4404 HRESULT CDECL wined3d_get_output_desc(const struct wined3d *wined3d, unsigned int adapter_idx,
4405 struct wined3d_output_desc *desc)
4407 enum wined3d_display_rotation rotation;
4408 const struct wined3d_adapter *adapter;
4409 struct wined3d_display_mode mode;
4410 HMONITOR monitor;
4411 HRESULT hr;
4413 TRACE("wined3d %p, adapter_idx %u, desc %p.\n", wined3d, adapter_idx, desc);
4415 if (adapter_idx >= wined3d->adapter_count)
4416 return WINED3DERR_INVALIDCALL;
4418 adapter = &wined3d->adapters[adapter_idx];
4419 if (!(monitor = MonitorFromPoint(adapter->monitor_position, MONITOR_DEFAULTTOPRIMARY)))
4420 return WINED3DERR_INVALIDCALL;
4422 if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx, &mode, &rotation)))
4423 return hr;
4425 memcpy(desc->device_name, adapter->DeviceName, sizeof(desc->device_name));
4426 SetRect(&desc->desktop_rect, 0, 0, mode.width, mode.height);
4427 OffsetRect(&desc->desktop_rect, adapter->monitor_position.x, adapter->monitor_position.y);
4428 /* FIXME: We should get this from EnumDisplayDevices() when the adapters
4429 * are created. */
4430 desc->attached_to_desktop = TRUE;
4431 desc->rotation = rotation;
4432 desc->monitor = monitor;
4434 return WINED3D_OK;
4437 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
4438 of the same bpp but different resolutions */
4440 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
4441 UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT adapter_idx,
4442 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering)
4444 const struct wined3d_adapter *adapter;
4445 const struct wined3d_format *format;
4446 unsigned int i = 0;
4447 unsigned int j = 0;
4448 UINT format_bits;
4449 DEVMODEW mode;
4451 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x.\n",
4452 wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering);
4454 if (adapter_idx >= wined3d->adapter_count)
4455 return 0;
4457 adapter = &wined3d->adapters[adapter_idx];
4458 format = wined3d_get_format(&adapter->gl_info, format_id, WINED3DUSAGE_RENDERTARGET);
4459 format_bits = format->byte_count * CHAR_BIT;
4461 memset(&mode, 0, sizeof(mode));
4462 mode.dmSize = sizeof(mode);
4464 while (EnumDisplaySettingsExW(adapter->DeviceName, j++, &mode, 0))
4466 if (mode.dmFields & DM_DISPLAYFLAGS)
4468 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
4469 && (mode.u2.dmDisplayFlags & DM_INTERLACED))
4470 continue;
4472 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
4473 && !(mode.u2.dmDisplayFlags & DM_INTERLACED))
4474 continue;
4477 if (format_id == WINED3DFMT_UNKNOWN)
4479 /* This is for d3d8, do not enumerate P8 here. */
4480 if (mode.dmBitsPerPel == 32 || mode.dmBitsPerPel == 16) ++i;
4482 else if (mode.dmBitsPerPel == format_bits)
4484 ++i;
4488 TRACE("Returning %u matching modes (out of %u total) for adapter %u.\n", i, j, adapter_idx);
4490 return i;
4493 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
4494 HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT adapter_idx,
4495 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering,
4496 UINT mode_idx, struct wined3d_display_mode *mode)
4498 const struct wined3d_adapter *adapter;
4499 const struct wined3d_format *format;
4500 UINT format_bits;
4501 DEVMODEW m;
4502 UINT i = 0;
4503 int j = 0;
4505 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x, mode_idx %u, mode %p.\n",
4506 wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering, mode_idx, mode);
4508 if (!mode || adapter_idx >= wined3d->adapter_count)
4509 return WINED3DERR_INVALIDCALL;
4511 adapter = &wined3d->adapters[adapter_idx];
4512 format = wined3d_get_format(&adapter->gl_info, format_id, WINED3DUSAGE_RENDERTARGET);
4513 format_bits = format->byte_count * CHAR_BIT;
4515 memset(&m, 0, sizeof(m));
4516 m.dmSize = sizeof(m);
4518 while (i <= mode_idx)
4520 if (!EnumDisplaySettingsExW(adapter->DeviceName, j++, &m, 0))
4522 WARN("Invalid mode_idx %u.\n", mode_idx);
4523 return WINED3DERR_INVALIDCALL;
4526 if (m.dmFields & DM_DISPLAYFLAGS)
4528 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
4529 && (m.u2.dmDisplayFlags & DM_INTERLACED))
4530 continue;
4532 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
4533 && !(m.u2.dmDisplayFlags & DM_INTERLACED))
4534 continue;
4537 if (format_id == WINED3DFMT_UNKNOWN)
4539 /* This is for d3d8, do not enumerate P8 here. */
4540 if (m.dmBitsPerPel == 32 || m.dmBitsPerPel == 16) ++i;
4542 else if (m.dmBitsPerPel == format_bits)
4544 ++i;
4548 mode->width = m.dmPelsWidth;
4549 mode->height = m.dmPelsHeight;
4550 mode->refresh_rate = DEFAULT_REFRESH_RATE;
4551 if (m.dmFields & DM_DISPLAYFREQUENCY)
4552 mode->refresh_rate = m.dmDisplayFrequency;
4554 if (format_id == WINED3DFMT_UNKNOWN)
4555 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
4556 else
4557 mode->format_id = format_id;
4559 if (!(m.dmFields & DM_DISPLAYFLAGS))
4560 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
4561 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
4562 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
4563 else
4564 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
4566 TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
4567 m.dmBitsPerPel, debug_d3dformat(mode->format_id), mode->scanline_ordering);
4569 return WINED3D_OK;
4572 HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *wined3d,
4573 unsigned int adapter_idx, struct wined3d_display_mode *mode)
4575 unsigned int i, j, mode_count, matching_mode_count, closest;
4576 struct wined3d_display_mode **matching_modes;
4577 struct wined3d_display_mode *modes;
4578 HRESULT hr;
4580 TRACE("wined3d %p, adapter_idx %u, mode %p.\n", wined3d, adapter_idx, mode);
4582 if (!(mode_count = wined3d_get_adapter_mode_count(wined3d, adapter_idx,
4583 mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN)))
4585 WARN("Adapter has 0 matching modes.\n");
4586 return E_FAIL;
4589 if (!(modes = wined3d_calloc(mode_count, sizeof(*modes))))
4590 return E_OUTOFMEMORY;
4591 if (!(matching_modes = wined3d_calloc(mode_count, sizeof(*matching_modes))))
4593 HeapFree(GetProcessHeap(), 0, modes);
4594 return E_OUTOFMEMORY;
4597 for (i = 0; i < mode_count; ++i)
4599 if (FAILED(hr = wined3d_enum_adapter_modes(wined3d, adapter_idx,
4600 mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN, i, &modes[i])))
4602 HeapFree(GetProcessHeap(), 0, matching_modes);
4603 HeapFree(GetProcessHeap(), 0, modes);
4604 return hr;
4606 matching_modes[i] = &modes[i];
4609 matching_mode_count = mode_count;
4611 if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
4613 for (i = 0, j = 0; i < matching_mode_count; ++i)
4615 if (matching_modes[i]->scanline_ordering == mode->scanline_ordering)
4616 matching_modes[j++] = matching_modes[i];
4618 if (j > 0)
4619 matching_mode_count = j;
4622 if (mode->refresh_rate)
4624 for (i = 0, j = 0; i < matching_mode_count; ++i)
4626 if (matching_modes[i]->refresh_rate == mode->refresh_rate)
4627 matching_modes[j++] = matching_modes[i];
4629 if (j > 0)
4630 matching_mode_count = j;
4633 if (!mode->width || !mode->height)
4635 struct wined3d_display_mode current_mode;
4636 if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx,
4637 &current_mode, NULL)))
4639 HeapFree(GetProcessHeap(), 0, matching_modes);
4640 HeapFree(GetProcessHeap(), 0, modes);
4641 return hr;
4643 mode->width = current_mode.width;
4644 mode->height = current_mode.height;
4647 closest = ~0u;
4648 for (i = 0, j = 0; i < matching_mode_count; ++i)
4650 unsigned int d = abs(mode->width - matching_modes[i]->width)
4651 + abs(mode->height - matching_modes[i]->height);
4653 if (closest > d)
4655 closest = d;
4656 j = i;
4660 *mode = *matching_modes[j];
4662 HeapFree(GetProcessHeap(), 0, matching_modes);
4663 HeapFree(GetProcessHeap(), 0, modes);
4665 TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
4666 mode->refresh_rate, debug_d3dformat(mode->format_id),
4667 mode->scanline_ordering);
4669 return WINED3D_OK;
4672 HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx,
4673 struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
4675 const struct wined3d_adapter *adapter;
4676 DEVMODEW m;
4678 TRACE("wined3d %p, adapter_idx %u, display_mode %p, rotation %p.\n",
4679 wined3d, adapter_idx, mode, rotation);
4681 if (!mode || adapter_idx >= wined3d->adapter_count)
4682 return WINED3DERR_INVALIDCALL;
4684 adapter = &wined3d->adapters[adapter_idx];
4686 memset(&m, 0, sizeof(m));
4687 m.dmSize = sizeof(m);
4689 EnumDisplaySettingsExW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &m, 0);
4690 mode->width = m.dmPelsWidth;
4691 mode->height = m.dmPelsHeight;
4692 mode->refresh_rate = DEFAULT_REFRESH_RATE;
4693 if (m.dmFields & DM_DISPLAYFREQUENCY)
4694 mode->refresh_rate = m.dmDisplayFrequency;
4695 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
4697 /* Lie about the format. X11 can't change the color depth, and some apps
4698 * are pretty angry if they SetDisplayMode from 24 to 16 bpp and find out
4699 * that GetDisplayMode still returns 24 bpp. This should probably be
4700 * handled in winex11 instead. */
4701 if (adapter->screen_format && adapter->screen_format != mode->format_id)
4703 WARN("Overriding format %s with stored format %s.\n",
4704 debug_d3dformat(mode->format_id),
4705 debug_d3dformat(adapter->screen_format));
4706 mode->format_id = adapter->screen_format;
4709 if (!(m.dmFields & DM_DISPLAYFLAGS))
4710 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
4711 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
4712 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
4713 else
4714 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
4716 if (rotation)
4718 switch (m.u1.s2.dmDisplayOrientation)
4720 case DMDO_DEFAULT:
4721 *rotation = WINED3D_DISPLAY_ROTATION_0;
4722 break;
4723 case DMDO_90:
4724 *rotation = WINED3D_DISPLAY_ROTATION_90;
4725 break;
4726 case DMDO_180:
4727 *rotation = WINED3D_DISPLAY_ROTATION_180;
4728 break;
4729 case DMDO_270:
4730 *rotation = WINED3D_DISPLAY_ROTATION_270;
4731 break;
4732 default:
4733 FIXME("Unhandled display rotation %#x.\n", m.u1.s2.dmDisplayOrientation);
4734 *rotation = WINED3D_DISPLAY_ROTATION_UNSPECIFIED;
4735 break;
4739 TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
4740 mode->refresh_rate, debug_d3dformat(mode->format_id),
4741 mode->scanline_ordering);
4742 return WINED3D_OK;
4745 HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d,
4746 UINT adapter_idx, const struct wined3d_display_mode *mode)
4748 struct wined3d_adapter *adapter;
4749 DEVMODEW new_mode, current_mode;
4750 RECT clip_rc;
4751 LONG ret;
4752 enum wined3d_format_id new_format_id;
4754 TRACE("wined3d %p, adapter_idx %u, mode %p.\n", wined3d, adapter_idx, mode);
4756 if (adapter_idx >= wined3d->adapter_count)
4757 return WINED3DERR_INVALIDCALL;
4758 adapter = &wined3d->adapters[adapter_idx];
4760 memset(&new_mode, 0, sizeof(new_mode));
4761 new_mode.dmSize = sizeof(new_mode);
4762 memset(&current_mode, 0, sizeof(current_mode));
4763 current_mode.dmSize = sizeof(current_mode);
4764 if (mode)
4766 const struct wined3d_format *format;
4768 TRACE("mode %ux%u@%u %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
4769 debug_d3dformat(mode->format_id), mode->scanline_ordering);
4771 format = wined3d_get_format(&adapter->gl_info, mode->format_id, WINED3DUSAGE_RENDERTARGET);
4773 new_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
4774 new_mode.dmBitsPerPel = format->byte_count * CHAR_BIT;
4775 new_mode.dmPelsWidth = mode->width;
4776 new_mode.dmPelsHeight = mode->height;
4778 new_mode.dmDisplayFrequency = mode->refresh_rate;
4779 if (mode->refresh_rate)
4780 new_mode.dmFields |= DM_DISPLAYFREQUENCY;
4782 if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
4784 new_mode.dmFields |= DM_DISPLAYFLAGS;
4785 if (mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED)
4786 new_mode.u2.dmDisplayFlags |= DM_INTERLACED;
4788 new_format_id = mode->format_id;
4790 else
4792 if (!EnumDisplaySettingsW(adapter->DeviceName, ENUM_REGISTRY_SETTINGS, &new_mode))
4794 ERR("Failed to read mode from registry.\n");
4795 return WINED3DERR_NOTAVAILABLE;
4797 new_format_id = pixelformat_for_depth(new_mode.dmBitsPerPel);
4800 /* Only change the mode if necessary. */
4801 if (!EnumDisplaySettingsW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &current_mode))
4803 ERR("Failed to get current display mode.\n");
4805 else if (current_mode.dmPelsWidth == new_mode.dmPelsWidth
4806 && current_mode.dmPelsHeight == new_mode.dmPelsHeight
4807 && current_mode.dmBitsPerPel == new_mode.dmBitsPerPel
4808 && (current_mode.dmDisplayFrequency == new_mode.dmDisplayFrequency
4809 || !(new_mode.dmFields & DM_DISPLAYFREQUENCY))
4810 && (current_mode.u2.dmDisplayFlags == new_mode.u2.dmDisplayFlags
4811 || !(new_mode.dmFields & DM_DISPLAYFLAGS)))
4813 TRACE("Skipping redundant mode setting call.\n");
4814 adapter->screen_format = new_format_id;
4815 return WINED3D_OK;
4818 ret = ChangeDisplaySettingsExW(adapter->DeviceName, &new_mode, NULL, CDS_FULLSCREEN, NULL);
4819 if (ret != DISP_CHANGE_SUCCESSFUL)
4821 if (new_mode.dmFields & DM_DISPLAYFREQUENCY)
4823 WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate.\n");
4824 new_mode.dmFields &= ~DM_DISPLAYFREQUENCY;
4825 new_mode.dmDisplayFrequency = 0;
4826 ret = ChangeDisplaySettingsExW(adapter->DeviceName, &new_mode, NULL, CDS_FULLSCREEN, NULL);
4828 if (ret != DISP_CHANGE_SUCCESSFUL)
4829 return WINED3DERR_NOTAVAILABLE;
4832 /* Store the new values. */
4833 adapter->screen_format = new_format_id;
4835 /* And finally clip mouse to our screen. */
4836 SetRect(&clip_rc, 0, 0, new_mode.dmPelsWidth, new_mode.dmPelsHeight);
4837 ClipCursor(&clip_rc);
4839 return WINED3D_OK;
4842 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
4843 and fields being inserted in the middle, a new structure is used in place */
4844 HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d,
4845 UINT adapter_idx, DWORD flags, struct wined3d_adapter_identifier *identifier)
4847 const struct wined3d_adapter *adapter;
4848 size_t len;
4850 TRACE("wined3d %p, adapter_idx %u, flags %#x, identifier %p.\n",
4851 wined3d, adapter_idx, flags, identifier);
4853 if (adapter_idx >= wined3d->adapter_count)
4854 return WINED3DERR_INVALIDCALL;
4856 adapter = &wined3d->adapters[adapter_idx];
4858 if (identifier->driver_size)
4860 const char *name = adapter->driver_info.name;
4861 len = min(strlen(name), identifier->driver_size - 1);
4862 memcpy(identifier->driver, name, len);
4863 memset(&identifier->driver[len], 0, identifier->driver_size - len);
4866 if (identifier->description_size)
4868 const char *description = adapter->driver_info.description;
4869 len = min(strlen(description), identifier->description_size - 1);
4870 memcpy(identifier->description, description, len);
4871 memset(&identifier->description[len], 0, identifier->description_size - len);
4874 /* Note that d3d8 doesn't supply a device name. */
4875 if (identifier->device_name_size)
4877 if (!WideCharToMultiByte(CP_ACP, 0, adapter->DeviceName, -1, identifier->device_name,
4878 identifier->device_name_size, NULL, NULL))
4880 ERR("Failed to convert device name, last error %#x.\n", GetLastError());
4881 return WINED3DERR_INVALIDCALL;
4885 identifier->driver_version.u.HighPart = adapter->driver_info.version_high;
4886 identifier->driver_version.u.LowPart = adapter->driver_info.version_low;
4887 identifier->vendor_id = adapter->driver_info.vendor;
4888 identifier->device_id = adapter->driver_info.device;
4889 identifier->subsystem_id = 0;
4890 identifier->revision = 0;
4891 memcpy(&identifier->device_identifier, &IID_D3DDEVICE_D3DUID, sizeof(identifier->device_identifier));
4892 identifier->whql_level = (flags & WINED3DENUM_NO_WHQL_LEVEL) ? 0 : 1;
4893 memcpy(&identifier->adapter_luid, &adapter->luid, sizeof(identifier->adapter_luid));
4894 identifier->video_memory = min(~(SIZE_T)0, adapter->vram_bytes);
4896 return WINED3D_OK;
4899 HRESULT CDECL wined3d_get_adapter_raster_status(const struct wined3d *wined3d, UINT adapter_idx,
4900 struct wined3d_raster_status *raster_status)
4902 LONGLONG freq_per_frame, freq_per_line;
4903 LARGE_INTEGER counter, freq_per_sec;
4904 struct wined3d_display_mode mode;
4905 static UINT once;
4907 if (!once++)
4908 FIXME("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
4909 wined3d, adapter_idx, raster_status);
4910 else
4911 WARN("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
4912 wined3d, adapter_idx, raster_status);
4914 /* Obtaining the raster status is a widely implemented but optional
4915 * feature. When this method returns OK StarCraft 2 expects the
4916 * raster_status->InVBlank value to actually change over time.
4917 * And Endless Alice Crysis doesn't care even if this method fails.
4918 * Thus this method returns OK and fakes raster_status by
4919 * QueryPerformanceCounter. */
4921 if (!QueryPerformanceCounter(&counter) || !QueryPerformanceFrequency(&freq_per_sec))
4922 return WINED3DERR_INVALIDCALL;
4923 if (FAILED(wined3d_get_adapter_display_mode(wined3d, adapter_idx, &mode, NULL)))
4924 return WINED3DERR_INVALIDCALL;
4925 if (mode.refresh_rate == DEFAULT_REFRESH_RATE)
4926 mode.refresh_rate = 60;
4928 freq_per_frame = freq_per_sec.QuadPart / mode.refresh_rate;
4929 /* Assume 20 scan lines in the vertical blank. */
4930 freq_per_line = freq_per_frame / (mode.height + 20);
4931 raster_status->scan_line = (counter.QuadPart % freq_per_frame) / freq_per_line;
4932 if (raster_status->scan_line < mode.height)
4933 raster_status->in_vblank = FALSE;
4934 else
4936 raster_status->scan_line = 0;
4937 raster_status->in_vblank = TRUE;
4940 TRACE("Returning fake value, in_vblank %u, scan_line %u.\n",
4941 raster_status->in_vblank, raster_status->scan_line);
4943 return WINED3D_OK;
4946 static BOOL wined3d_check_pixel_format_color(const struct wined3d_gl_info *gl_info,
4947 const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
4949 /* Float formats need FBOs. If FBOs are used this function isn't called */
4950 if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
4951 return FALSE;
4953 /* Probably a RGBA_float or color index mode. */
4954 if (cfg->iPixelType != WGL_TYPE_RGBA_ARB)
4955 return FALSE;
4957 if (cfg->redSize < format->red_size
4958 || cfg->greenSize < format->green_size
4959 || cfg->blueSize < format->blue_size
4960 || cfg->alphaSize < format->alpha_size)
4961 return FALSE;
4963 return TRUE;
4966 static BOOL wined3d_check_pixel_format_depth(const struct wined3d_gl_info *gl_info,
4967 const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
4969 BOOL lockable = FALSE;
4971 /* Float formats need FBOs. If FBOs are used this function isn't called */
4972 if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
4973 return FALSE;
4975 if ((format->id == WINED3DFMT_D16_LOCKABLE) || (format->id == WINED3DFMT_D32_FLOAT))
4976 lockable = TRUE;
4978 /* On some modern cards like the Geforce8/9, GLX doesn't offer some
4979 * depth/stencil formats which D3D9 reports. We can safely report
4980 * "compatible" formats (e.g. D24 can be used for D16) as long as we
4981 * aren't dealing with a lockable format. This also helps D3D <= 7 as they
4982 * expect D16 which isn't offered without this on Geforce8 cards. */
4983 if (!(cfg->depthSize == format->depth_size || (!lockable && cfg->depthSize > format->depth_size)))
4984 return FALSE;
4986 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also
4987 * need a format without stencil. We can allow a mismatch if the format
4988 * doesn't have any stencil bits. If it does have stencil bits the size
4989 * must match, or stencil wrapping would break. */
4990 if (format->stencil_size && cfg->stencilSize != format->stencil_size)
4991 return FALSE;
4993 return TRUE;
4996 HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d *wined3d,
4997 UINT adapter_idx, enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id,
4998 enum wined3d_format_id render_target_format_id, enum wined3d_format_id depth_stencil_format_id)
5000 const struct wined3d_format *rt_format;
5001 const struct wined3d_format *ds_format;
5002 const struct wined3d_adapter *adapter;
5004 TRACE("wined3d %p, adapter_idx %u, device_type %s,\n"
5005 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
5006 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
5007 debug_d3dformat(render_target_format_id), debug_d3dformat(depth_stencil_format_id));
5009 if (adapter_idx >= wined3d->adapter_count)
5010 return WINED3DERR_INVALIDCALL;
5012 adapter = &wined3d->adapters[adapter_idx];
5013 rt_format = wined3d_get_format(&adapter->gl_info, render_target_format_id, WINED3DUSAGE_RENDERTARGET);
5014 ds_format = wined3d_get_format(&adapter->gl_info, depth_stencil_format_id, WINED3DUSAGE_DEPTHSTENCIL);
5015 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
5017 if ((rt_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_RENDERTARGET)
5018 && (ds_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
5020 TRACE("Formats match.\n");
5021 return WINED3D_OK;
5024 else
5026 const struct wined3d_pixel_format *cfgs;
5027 unsigned int cfg_count;
5028 unsigned int i;
5030 cfgs = adapter->cfgs;
5031 cfg_count = adapter->cfg_count;
5032 for (i = 0; i < cfg_count; ++i)
5034 if (wined3d_check_pixel_format_color(&adapter->gl_info, &cfgs[i], rt_format)
5035 && wined3d_check_pixel_format_depth(&adapter->gl_info, &cfgs[i], ds_format))
5037 TRACE("Formats match.\n");
5038 return WINED3D_OK;
5043 TRACE("Unsupported format pair: %s and %s.\n",
5044 debug_d3dformat(render_target_format_id),
5045 debug_d3dformat(depth_stencil_format_id));
5047 return WINED3DERR_NOTAVAILABLE;
5050 HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3d, UINT adapter_idx,
5051 enum wined3d_device_type device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
5052 enum wined3d_multisample_type multisample_type, DWORD *quality_levels)
5054 const struct wined3d_gl_info *gl_info = &wined3d->adapters[adapter_idx].gl_info;
5055 const struct wined3d_format *format = wined3d_get_format(gl_info, surface_format_id, 0);
5056 HRESULT hr = WINED3D_OK;
5058 TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s, "
5059 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
5060 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(surface_format_id),
5061 windowed, multisample_type, quality_levels);
5063 if (adapter_idx >= wined3d->adapter_count)
5064 return WINED3DERR_INVALIDCALL;
5065 if (surface_format_id == WINED3DFMT_UNKNOWN)
5066 return WINED3DERR_INVALIDCALL;
5067 if (multisample_type < WINED3D_MULTISAMPLE_NONE)
5068 return WINED3DERR_INVALIDCALL;
5069 if (multisample_type > WINED3D_MULTISAMPLE_16_SAMPLES)
5071 FIXME("multisample_type %u not handled yet.\n", multisample_type);
5072 return WINED3DERR_NOTAVAILABLE;
5075 if (multisample_type && !(format->multisample_types & 1u << (multisample_type - 1)))
5076 hr = WINED3DERR_NOTAVAILABLE;
5078 if (SUCCEEDED(hr) || (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE && format->multisample_types))
5080 if (quality_levels)
5082 if (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE)
5083 *quality_levels = wined3d_popcount(format->multisample_types);
5084 else
5085 *quality_levels = 1;
5087 return WINED3D_OK;
5090 TRACE("Returning not supported.\n");
5091 return hr;
5094 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
5095 static BOOL CheckDepthStencilCapability(const struct wined3d_adapter *adapter,
5096 const struct wined3d_format *display_format, const struct wined3d_format *ds_format,
5097 enum wined3d_gl_resource_type gl_type)
5099 /* Only allow depth/stencil formats */
5100 if (!(ds_format->depth_size || ds_format->stencil_size)) return FALSE;
5102 /* Blacklist formats not supported on Windows */
5103 switch (ds_format->id)
5105 case WINED3DFMT_S1_UINT_D15_UNORM: /* Breaks the shadowvol2 dx7 sdk sample */
5106 case WINED3DFMT_S4X4_UINT_D24_UNORM:
5107 TRACE("[FAILED] - not supported on windows.\n");
5108 return FALSE;
5110 default:
5111 break;
5114 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
5116 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
5117 if (ds_format->flags[gl_type] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
5118 return TRUE;
5120 else
5122 unsigned int i;
5124 /* Walk through all WGL pixel formats to find a match */
5125 for (i = 0; i < adapter->cfg_count; ++i)
5127 const struct wined3d_pixel_format *cfg = &adapter->cfgs[i];
5128 if (wined3d_check_pixel_format_color(&adapter->gl_info, cfg, display_format)
5129 && wined3d_check_pixel_format_depth(&adapter->gl_info, cfg, ds_format))
5130 return TRUE;
5134 return FALSE;
5137 /* Check the render target capabilities of a format */
5138 static BOOL CheckRenderTargetCapability(const struct wined3d_adapter *adapter,
5139 const struct wined3d_format *adapter_format, const struct wined3d_format *check_format,
5140 enum wined3d_gl_resource_type gl_type)
5142 /* Filter out non-RT formats */
5143 if (!(check_format->flags[gl_type] & WINED3DFMT_FLAG_RENDERTARGET))
5144 return FALSE;
5145 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
5146 return TRUE;
5147 if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
5149 const struct wined3d_pixel_format *cfgs = adapter->cfgs;
5150 unsigned int i;
5152 /* In backbuffer mode the front and backbuffer share the same WGL
5153 * pixelformat. The format must match in RGB, alpha is allowed to be
5154 * different. (Only the backbuffer can have alpha.) */
5155 if (adapter_format->red_size != check_format->red_size
5156 || adapter_format->green_size != check_format->green_size
5157 || adapter_format->blue_size != check_format->blue_size)
5159 TRACE("[FAILED]\n");
5160 return FALSE;
5163 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
5164 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
5165 for (i = 0; i < adapter->cfg_count; ++i)
5167 if (cfgs[i].windowDrawable
5168 && wined3d_check_pixel_format_color(&adapter->gl_info, &cfgs[i], check_format))
5170 TRACE("Pixel format %d is compatible with format %s.\n",
5171 cfgs[i].iPixelFormat, debug_d3dformat(check_format->id));
5172 return TRUE;
5176 return FALSE;
5179 static BOOL wined3d_check_surface_capability(const struct wined3d_format *format, BOOL no3d)
5181 if (no3d)
5183 switch (format->id)
5185 case WINED3DFMT_B8G8R8_UNORM:
5186 TRACE("[FAILED] - Not enumerated on Windows.\n");
5187 return FALSE;
5188 case WINED3DFMT_B8G8R8A8_UNORM:
5189 case WINED3DFMT_B8G8R8X8_UNORM:
5190 case WINED3DFMT_B5G6R5_UNORM:
5191 case WINED3DFMT_B5G5R5X1_UNORM:
5192 case WINED3DFMT_B5G5R5A1_UNORM:
5193 case WINED3DFMT_B4G4R4A4_UNORM:
5194 case WINED3DFMT_B2G3R3_UNORM:
5195 case WINED3DFMT_A8_UNORM:
5196 case WINED3DFMT_B2G3R3A8_UNORM:
5197 case WINED3DFMT_B4G4R4X4_UNORM:
5198 case WINED3DFMT_R10G10B10A2_UNORM:
5199 case WINED3DFMT_R8G8B8A8_UNORM:
5200 case WINED3DFMT_R8G8B8X8_UNORM:
5201 case WINED3DFMT_R16G16_UNORM:
5202 case WINED3DFMT_B10G10R10A2_UNORM:
5203 case WINED3DFMT_R16G16B16A16_UNORM:
5204 case WINED3DFMT_P8_UINT:
5205 TRACE("[OK]\n");
5206 return TRUE;
5207 default:
5208 TRACE("[FAILED] - Not available on GDI surfaces.\n");
5209 return FALSE;
5213 if (format->glInternal)
5215 TRACE("[OK]\n");
5216 return TRUE;
5219 /* Reject other formats */
5220 TRACE("[FAILED]\n");
5221 return FALSE;
5224 /* OpenGL supports mipmapping on all formats. Wrapping is unsupported, but we
5225 * have to report mipmapping so we cannot reject WRAPANDMIP. Tests show that
5226 * Windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to
5227 * show that wrapping is supported. The lack of filtering will sort out the
5228 * mipmapping capability anyway.
5230 * For now lets report this on all formats, but in the future we may want to
5231 * restrict it to some should applications need that. */
5232 HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT adapter_idx,
5233 enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
5234 enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id)
5236 const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
5237 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
5238 const struct wined3d_format *adapter_format = wined3d_get_format(gl_info, adapter_format_id,
5239 WINED3DUSAGE_RENDERTARGET);
5240 const struct wined3d_format *format = wined3d_get_format(gl_info, check_format_id, usage);
5241 enum wined3d_gl_resource_type gl_type, gl_type_end;
5242 DWORD format_flags = 0;
5243 DWORD allowed_usage;
5245 TRACE("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s, "
5246 "resource_type %s, check_format %s.\n",
5247 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
5248 debug_d3dusage(usage), debug_d3dusagequery(usage), debug_d3dresourcetype(resource_type),
5249 debug_d3dformat(check_format_id));
5251 if (adapter_idx >= wined3d->adapter_count)
5252 return WINED3DERR_INVALIDCALL;
5254 switch (resource_type)
5256 case WINED3D_RTYPE_NONE:
5257 allowed_usage = WINED3DUSAGE_DEPTHSTENCIL
5258 | WINED3DUSAGE_RENDERTARGET;
5259 gl_type = WINED3D_GL_RES_TYPE_TEX_2D;
5260 gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D;
5261 break;
5263 case WINED3D_RTYPE_TEXTURE_2D:
5264 allowed_usage = WINED3DUSAGE_DEPTHSTENCIL
5265 | WINED3DUSAGE_RENDERTARGET
5266 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
5267 if (usage & WINED3DUSAGE_RENDERTARGET)
5268 allowed_usage |= WINED3DUSAGE_QUERY_SRGBWRITE;
5269 if (!(usage & WINED3DUSAGE_TEXTURE))
5271 if (!wined3d_check_surface_capability(format, wined3d->flags & WINED3D_NO3D))
5273 TRACE("[FAILED] - Not supported for plain surfaces.\n");
5274 return WINED3DERR_NOTAVAILABLE;
5277 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_RB;
5278 break;
5280 allowed_usage |= WINED3DUSAGE_AUTOGENMIPMAP
5281 | WINED3DUSAGE_DYNAMIC
5282 | WINED3DUSAGE_LEGACY_CUBEMAP
5283 | WINED3DUSAGE_SOFTWAREPROCESSING
5284 | WINED3DUSAGE_TEXTURE
5285 | WINED3DUSAGE_QUERY_FILTER
5286 | WINED3DUSAGE_QUERY_LEGACYBUMPMAP
5287 | WINED3DUSAGE_QUERY_SRGBREAD
5288 | WINED3DUSAGE_QUERY_SRGBWRITE
5289 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
5290 | WINED3DUSAGE_QUERY_WRAPANDMIP;
5291 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_2D;
5292 if (usage & WINED3DUSAGE_LEGACY_CUBEMAP)
5294 allowed_usage &= ~(WINED3DUSAGE_DEPTHSTENCIL | WINED3DUSAGE_QUERY_LEGACYBUMPMAP);
5295 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_CUBE;
5297 else if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
5298 && (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SHADOW)
5299 && !gl_info->supported[ARB_SHADOW])
5301 TRACE("[FAILED] - No shadow sampler support.\n");
5302 return WINED3DERR_NOTAVAILABLE;
5304 break;
5306 case WINED3D_RTYPE_TEXTURE_3D:
5307 allowed_usage = WINED3DUSAGE_DYNAMIC
5308 | WINED3DUSAGE_SOFTWAREPROCESSING
5309 | WINED3DUSAGE_TEXTURE
5310 | WINED3DUSAGE_QUERY_FILTER
5311 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
5312 | WINED3DUSAGE_QUERY_SRGBREAD
5313 | WINED3DUSAGE_QUERY_SRGBWRITE
5314 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
5315 | WINED3DUSAGE_QUERY_WRAPANDMIP;
5316 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D;
5317 break;
5319 default:
5320 FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type));
5321 return WINED3DERR_NOTAVAILABLE;
5324 if ((usage & allowed_usage) != usage)
5326 TRACE("Requested usage %#x, but resource type %s only allows %#x.\n",
5327 usage, debug_d3dresourcetype(resource_type), allowed_usage);
5328 return WINED3DERR_NOTAVAILABLE;
5331 if (usage & WINED3DUSAGE_TEXTURE)
5332 format_flags |= WINED3DFMT_FLAG_TEXTURE;
5333 if (usage & WINED3DUSAGE_QUERY_FILTER)
5334 format_flags |= WINED3DFMT_FLAG_FILTERING;
5335 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
5336 format_flags |= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
5337 if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
5338 format_flags |= WINED3DFMT_FLAG_SRGB_READ;
5339 if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
5340 format_flags |= WINED3DFMT_FLAG_SRGB_WRITE;
5341 if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
5342 format_flags |= WINED3DFMT_FLAG_VTF;
5343 if (usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP)
5344 format_flags |= WINED3DFMT_FLAG_BUMPMAP;
5346 if ((format_flags & WINED3DFMT_FLAG_TEXTURE) && (wined3d->flags & WINED3D_NO3D))
5348 TRACE("Requested texturing support, but wined3d was created with WINED3D_NO3D.\n");
5349 return WINED3DERR_NOTAVAILABLE;
5352 if ((usage & WINED3DUSAGE_AUTOGENMIPMAP) && !gl_info->supported[SGIS_GENERATE_MIPMAP])
5354 TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n");
5355 return WINED3DOK_NOAUTOGEN;
5358 for (; gl_type <= gl_type_end; ++gl_type)
5360 if ((format->flags[gl_type] & format_flags) != format_flags)
5362 TRACE("Requested format flags %#x, but format %s only has %#x.\n",
5363 format_flags, debug_d3dformat(check_format_id), format->flags[gl_type]);
5364 return WINED3DERR_NOTAVAILABLE;
5367 if ((usage & WINED3DUSAGE_RENDERTARGET)
5368 && !CheckRenderTargetCapability(adapter, adapter_format, format, gl_type))
5370 TRACE("Requested WINED3DUSAGE_RENDERTARGET, but format %s is not supported for render targets.\n",
5371 debug_d3dformat(check_format_id));
5372 return WINED3DERR_NOTAVAILABLE;
5375 /* 3D depth / stencil textures are never supported. */
5376 if (usage == WINED3DUSAGE_DEPTHSTENCIL && gl_type == WINED3D_GL_RES_TYPE_TEX_3D)
5377 continue;
5379 if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
5380 && !CheckDepthStencilCapability(adapter, adapter_format, format, gl_type))
5382 TRACE("Requested WINED3DUSAGE_DEPTHSTENCIL, but format %s is not supported for depth / stencil buffers.\n",
5383 debug_d3dformat(check_format_id));
5384 return WINED3DERR_NOTAVAILABLE;
5388 return WINED3D_OK;
5391 UINT CDECL wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT adapter_idx,
5392 enum wined3d_format_id format_id, UINT width)
5394 const struct wined3d_gl_info *gl_info;
5395 unsigned int row_pitch, slice_pitch;
5397 TRACE("wined3d %p, adapter_idx %u, format_id %s, width %u.\n",
5398 wined3d, adapter_idx, debug_d3dformat(format_id), width);
5400 if (adapter_idx >= wined3d->adapter_count)
5401 return ~0u;
5403 gl_info = &wined3d->adapters[adapter_idx].gl_info;
5404 wined3d_format_calculate_pitch(wined3d_get_format(gl_info, format_id, 0),
5405 1, width, 1, &row_pitch, &slice_pitch);
5407 return row_pitch;
5410 HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d *wined3d, UINT adapter_idx,
5411 enum wined3d_device_type device_type, enum wined3d_format_id src_format, enum wined3d_format_id dst_format)
5413 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
5414 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(src_format),
5415 debug_d3dformat(dst_format));
5417 return WINED3D_OK;
5420 HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adapter_idx,
5421 enum wined3d_device_type device_type, enum wined3d_format_id display_format,
5422 enum wined3d_format_id backbuffer_format, BOOL windowed)
5424 BOOL present_conversion = wined3d->flags & WINED3D_PRESENT_CONVERSION;
5426 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
5427 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(display_format),
5428 debug_d3dformat(backbuffer_format), windowed);
5430 if (adapter_idx >= wined3d->adapter_count)
5431 return WINED3DERR_INVALIDCALL;
5433 /* The task of this function is to check whether a certain display / backbuffer format
5434 * combination is available on the given adapter. In fullscreen mode microsoft specified
5435 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
5436 * and display format should match exactly.
5437 * In windowed mode format conversion can occur and this depends on the driver. */
5439 /* There are only 4 display formats. */
5440 if (!(display_format == WINED3DFMT_B5G6R5_UNORM
5441 || display_format == WINED3DFMT_B5G5R5X1_UNORM
5442 || display_format == WINED3DFMT_B8G8R8X8_UNORM
5443 || display_format == WINED3DFMT_B10G10R10A2_UNORM))
5445 TRACE("Format %s is not supported as display format.\n", debug_d3dformat(display_format));
5446 return WINED3DERR_NOTAVAILABLE;
5449 if (!windowed)
5451 /* If the requested display format is not available, don't continue. */
5452 if (!wined3d_get_adapter_mode_count(wined3d, adapter_idx,
5453 display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN))
5455 TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format));
5456 return WINED3DERR_NOTAVAILABLE;
5459 present_conversion = FALSE;
5461 else if (display_format == WINED3DFMT_B10G10R10A2_UNORM)
5463 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode. */
5464 TRACE("Unsupported format combination %s / %s in windowed mode.\n",
5465 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5466 return WINED3DERR_NOTAVAILABLE;
5469 if (present_conversion)
5471 /* Use the display format as back buffer format if the latter is
5472 * WINED3DFMT_UNKNOWN. */
5473 if (backbuffer_format == WINED3DFMT_UNKNOWN)
5474 backbuffer_format = display_format;
5476 if (FAILED(wined3d_check_device_format_conversion(wined3d, adapter_idx,
5477 device_type, backbuffer_format, display_format)))
5479 TRACE("Format conversion from %s to %s not supported.\n",
5480 debug_d3dformat(backbuffer_format), debug_d3dformat(display_format));
5481 return WINED3DERR_NOTAVAILABLE;
5484 else
5486 /* When format conversion from the back buffer format to the display
5487 * format is not allowed, only a limited number of combinations are
5488 * valid. */
5490 if (display_format == WINED3DFMT_B5G6R5_UNORM && backbuffer_format != WINED3DFMT_B5G6R5_UNORM)
5492 TRACE("Unsupported format combination %s / %s.\n",
5493 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5494 return WINED3DERR_NOTAVAILABLE;
5497 if (display_format == WINED3DFMT_B5G5R5X1_UNORM
5498 && !(backbuffer_format == WINED3DFMT_B5G5R5X1_UNORM || backbuffer_format == WINED3DFMT_B5G5R5A1_UNORM))
5500 TRACE("Unsupported format combination %s / %s.\n",
5501 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5502 return WINED3DERR_NOTAVAILABLE;
5505 if (display_format == WINED3DFMT_B8G8R8X8_UNORM
5506 && !(backbuffer_format == WINED3DFMT_B8G8R8X8_UNORM || backbuffer_format == WINED3DFMT_B8G8R8A8_UNORM))
5508 TRACE("Unsupported format combination %s / %s.\n",
5509 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5510 return WINED3DERR_NOTAVAILABLE;
5513 if (display_format == WINED3DFMT_B10G10R10A2_UNORM
5514 && backbuffer_format != WINED3DFMT_B10G10R10A2_UNORM)
5516 TRACE("Unsupported format combination %s / %s.\n",
5517 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5518 return WINED3DERR_NOTAVAILABLE;
5522 /* Validate that the back buffer format is usable for render targets. */
5523 if (FAILED(wined3d_check_device_format(wined3d, adapter_idx, device_type, display_format,
5524 WINED3DUSAGE_RENDERTARGET, WINED3D_RTYPE_TEXTURE_2D, backbuffer_format)))
5526 TRACE("Format %s not allowed for render targets.\n", debug_d3dformat(backbuffer_format));
5527 return WINED3DERR_NOTAVAILABLE;
5530 return WINED3D_OK;
5533 HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapter_idx,
5534 enum wined3d_device_type device_type, WINED3DCAPS *caps)
5536 const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
5537 const struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
5538 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
5539 struct wined3d_vertex_caps vertex_caps;
5540 DWORD ckey_caps, blit_caps, fx_caps;
5541 struct fragment_caps fragment_caps;
5542 struct shader_caps shader_caps;
5544 TRACE("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
5545 wined3d, adapter_idx, debug_d3ddevicetype(device_type), caps);
5547 if (adapter_idx >= wined3d->adapter_count)
5548 return WINED3DERR_INVALIDCALL;
5550 caps->DeviceType = (device_type == WINED3D_DEVICE_TYPE_HAL) ? WINED3D_DEVICE_TYPE_HAL : WINED3D_DEVICE_TYPE_REF;
5551 caps->AdapterOrdinal = adapter_idx;
5553 caps->Caps = 0;
5554 caps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED |
5555 WINED3DCAPS2_FULLSCREENGAMMA |
5556 WINED3DCAPS2_DYNAMICTEXTURES;
5557 if (gl_info->supported[SGIS_GENERATE_MIPMAP])
5558 caps->Caps2 |= WINED3DCAPS2_CANAUTOGENMIPMAP;
5560 caps->Caps3 = WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD |
5561 WINED3DCAPS3_COPY_TO_VIDMEM |
5562 WINED3DCAPS3_COPY_TO_SYSTEMMEM;
5564 caps->PresentationIntervals = WINED3DPRESENT_INTERVAL_IMMEDIATE |
5565 WINED3DPRESENT_INTERVAL_ONE;
5567 caps->CursorCaps = WINED3DCURSORCAPS_COLOR |
5568 WINED3DCURSORCAPS_LOWRES;
5570 caps->DevCaps = WINED3DDEVCAPS_FLOATTLVERTEX |
5571 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY |
5572 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY|
5573 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY |
5574 WINED3DDEVCAPS_DRAWPRIMTLVERTEX |
5575 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT |
5576 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY |
5577 WINED3DDEVCAPS_PUREDEVICE |
5578 WINED3DDEVCAPS_HWRASTERIZATION |
5579 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY |
5580 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY |
5581 WINED3DDEVCAPS_CANRENDERAFTERFLIP |
5582 WINED3DDEVCAPS_DRAWPRIMITIVES2 |
5583 WINED3DDEVCAPS_DRAWPRIMITIVES2EX;
5585 caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE |
5586 WINED3DPMISCCAPS_CULLCCW |
5587 WINED3DPMISCCAPS_CULLCW |
5588 WINED3DPMISCCAPS_COLORWRITEENABLE |
5589 WINED3DPMISCCAPS_CLIPTLVERTS |
5590 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
5591 WINED3DPMISCCAPS_MASKZ |
5592 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
5593 /* TODO:
5594 WINED3DPMISCCAPS_NULLREFERENCE
5595 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
5596 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
5597 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
5599 if (gl_info->supported[WINED3D_GL_BLEND_EQUATION])
5600 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_BLENDOP;
5601 if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
5602 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
5603 if (gl_info->supported[EXT_DRAW_BUFFERS2])
5604 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS;
5605 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB])
5606 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_POSTBLENDSRGBCONVERT;
5608 caps->RasterCaps = WINED3DPRASTERCAPS_DITHER |
5609 WINED3DPRASTERCAPS_PAT |
5610 WINED3DPRASTERCAPS_WFOG |
5611 WINED3DPRASTERCAPS_ZFOG |
5612 WINED3DPRASTERCAPS_FOGVERTEX |
5613 WINED3DPRASTERCAPS_FOGTABLE |
5614 WINED3DPRASTERCAPS_STIPPLE |
5615 WINED3DPRASTERCAPS_SUBPIXEL |
5616 WINED3DPRASTERCAPS_ZTEST |
5617 WINED3DPRASTERCAPS_SCISSORTEST |
5618 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
5619 WINED3DPRASTERCAPS_DEPTHBIAS;
5621 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
5623 caps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY |
5624 WINED3DPRASTERCAPS_ZBIAS |
5625 WINED3DPRASTERCAPS_MIPMAPLODBIAS;
5628 caps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
5629 WINED3DPCMPCAPS_EQUAL |
5630 WINED3DPCMPCAPS_GREATER |
5631 WINED3DPCMPCAPS_GREATEREQUAL |
5632 WINED3DPCMPCAPS_LESS |
5633 WINED3DPCMPCAPS_LESSEQUAL |
5634 WINED3DPCMPCAPS_NEVER |
5635 WINED3DPCMPCAPS_NOTEQUAL;
5637 /* WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA
5638 * are legacy settings for srcblend only. */
5639 caps->SrcBlendCaps = WINED3DPBLENDCAPS_BOTHINVSRCALPHA |
5640 WINED3DPBLENDCAPS_BOTHSRCALPHA |
5641 WINED3DPBLENDCAPS_DESTALPHA |
5642 WINED3DPBLENDCAPS_DESTCOLOR |
5643 WINED3DPBLENDCAPS_INVDESTALPHA |
5644 WINED3DPBLENDCAPS_INVDESTCOLOR |
5645 WINED3DPBLENDCAPS_INVSRCALPHA |
5646 WINED3DPBLENDCAPS_INVSRCCOLOR |
5647 WINED3DPBLENDCAPS_ONE |
5648 WINED3DPBLENDCAPS_SRCALPHA |
5649 WINED3DPBLENDCAPS_SRCALPHASAT |
5650 WINED3DPBLENDCAPS_SRCCOLOR |
5651 WINED3DPBLENDCAPS_ZERO;
5653 caps->DestBlendCaps = WINED3DPBLENDCAPS_DESTALPHA |
5654 WINED3DPBLENDCAPS_DESTCOLOR |
5655 WINED3DPBLENDCAPS_INVDESTALPHA |
5656 WINED3DPBLENDCAPS_INVDESTCOLOR |
5657 WINED3DPBLENDCAPS_INVSRCALPHA |
5658 WINED3DPBLENDCAPS_INVSRCCOLOR |
5659 WINED3DPBLENDCAPS_ONE |
5660 WINED3DPBLENDCAPS_SRCALPHA |
5661 WINED3DPBLENDCAPS_SRCCOLOR |
5662 WINED3DPBLENDCAPS_ZERO;
5664 if (gl_info->supported[ARB_BLEND_FUNC_EXTENDED])
5665 caps->DestBlendCaps |= WINED3DPBLENDCAPS_SRCALPHASAT;
5667 if (gl_info->supported[EXT_BLEND_COLOR])
5669 caps->SrcBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
5670 caps->DestBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
5674 caps->AlphaCmpCaps = WINED3DPCMPCAPS_ALWAYS |
5675 WINED3DPCMPCAPS_EQUAL |
5676 WINED3DPCMPCAPS_GREATER |
5677 WINED3DPCMPCAPS_GREATEREQUAL |
5678 WINED3DPCMPCAPS_LESS |
5679 WINED3DPCMPCAPS_LESSEQUAL |
5680 WINED3DPCMPCAPS_NEVER |
5681 WINED3DPCMPCAPS_NOTEQUAL;
5683 caps->ShadeCaps = WINED3DPSHADECAPS_SPECULARGOURAUDRGB |
5684 WINED3DPSHADECAPS_COLORGOURAUDRGB |
5685 WINED3DPSHADECAPS_ALPHAFLATBLEND |
5686 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND |
5687 WINED3DPSHADECAPS_COLORFLATRGB |
5688 WINED3DPSHADECAPS_FOGFLAT |
5689 WINED3DPSHADECAPS_FOGGOURAUD |
5690 WINED3DPSHADECAPS_SPECULARFLATRGB;
5692 caps->TextureCaps = WINED3DPTEXTURECAPS_ALPHA |
5693 WINED3DPTEXTURECAPS_ALPHAPALETTE |
5694 WINED3DPTEXTURECAPS_TRANSPARENCY |
5695 WINED3DPTEXTURECAPS_BORDER |
5696 WINED3DPTEXTURECAPS_MIPMAP |
5697 WINED3DPTEXTURECAPS_PROJECTED |
5698 WINED3DPTEXTURECAPS_PERSPECTIVE;
5700 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
5702 caps->TextureCaps |= WINED3DPTEXTURECAPS_POW2;
5703 if (gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] || gl_info->supported[ARB_TEXTURE_RECTANGLE])
5704 caps->TextureCaps |= WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL;
5707 if (gl_info->supported[EXT_TEXTURE3D])
5709 caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP |
5710 WINED3DPTEXTURECAPS_MIPVOLUMEMAP;
5711 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
5713 caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2;
5717 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
5719 caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP |
5720 WINED3DPTEXTURECAPS_MIPCUBEMAP;
5721 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
5723 caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP_POW2;
5727 caps->TextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
5728 WINED3DPTFILTERCAPS_MAGFPOINT |
5729 WINED3DPTFILTERCAPS_MINFLINEAR |
5730 WINED3DPTFILTERCAPS_MINFPOINT |
5731 WINED3DPTFILTERCAPS_MIPFLINEAR |
5732 WINED3DPTFILTERCAPS_MIPFPOINT |
5733 WINED3DPTFILTERCAPS_LINEAR |
5734 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
5735 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
5736 WINED3DPTFILTERCAPS_MIPLINEAR |
5737 WINED3DPTFILTERCAPS_MIPNEAREST |
5738 WINED3DPTFILTERCAPS_NEAREST;
5740 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
5742 caps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
5743 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
5746 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
5748 caps->CubeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
5749 WINED3DPTFILTERCAPS_MAGFPOINT |
5750 WINED3DPTFILTERCAPS_MINFLINEAR |
5751 WINED3DPTFILTERCAPS_MINFPOINT |
5752 WINED3DPTFILTERCAPS_MIPFLINEAR |
5753 WINED3DPTFILTERCAPS_MIPFPOINT |
5754 WINED3DPTFILTERCAPS_LINEAR |
5755 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
5756 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
5757 WINED3DPTFILTERCAPS_MIPLINEAR |
5758 WINED3DPTFILTERCAPS_MIPNEAREST |
5759 WINED3DPTFILTERCAPS_NEAREST;
5761 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
5763 caps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
5764 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
5767 else
5769 caps->CubeTextureFilterCaps = 0;
5772 if (gl_info->supported[EXT_TEXTURE3D])
5774 caps->VolumeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
5775 WINED3DPTFILTERCAPS_MAGFPOINT |
5776 WINED3DPTFILTERCAPS_MINFLINEAR |
5777 WINED3DPTFILTERCAPS_MINFPOINT |
5778 WINED3DPTFILTERCAPS_MIPFLINEAR |
5779 WINED3DPTFILTERCAPS_MIPFPOINT |
5780 WINED3DPTFILTERCAPS_LINEAR |
5781 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
5782 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
5783 WINED3DPTFILTERCAPS_MIPLINEAR |
5784 WINED3DPTFILTERCAPS_MIPNEAREST |
5785 WINED3DPTFILTERCAPS_NEAREST;
5787 else
5789 caps->VolumeTextureFilterCaps = 0;
5792 caps->TextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
5793 WINED3DPTADDRESSCAPS_CLAMP |
5794 WINED3DPTADDRESSCAPS_WRAP;
5796 if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
5798 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
5800 if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
5802 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
5804 if (gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE])
5806 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
5809 if (gl_info->supported[EXT_TEXTURE3D])
5811 caps->VolumeTextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
5812 WINED3DPTADDRESSCAPS_CLAMP |
5813 WINED3DPTADDRESSCAPS_WRAP;
5814 if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
5816 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
5818 if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
5820 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
5822 if (gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE])
5824 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
5827 else
5829 caps->VolumeTextureAddressCaps = 0;
5832 caps->LineCaps = WINED3DLINECAPS_TEXTURE |
5833 WINED3DLINECAPS_ZTEST |
5834 WINED3DLINECAPS_BLEND |
5835 WINED3DLINECAPS_ALPHACMP |
5836 WINED3DLINECAPS_FOG;
5837 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
5838 * idea how generating the smoothing alpha values works; the result is different
5841 caps->MaxTextureWidth = gl_info->limits.texture_size;
5842 caps->MaxTextureHeight = gl_info->limits.texture_size;
5844 if (gl_info->supported[EXT_TEXTURE3D])
5845 caps->MaxVolumeExtent = gl_info->limits.texture3d_size;
5846 else
5847 caps->MaxVolumeExtent = 0;
5849 caps->MaxTextureRepeat = 32768;
5850 caps->MaxTextureAspectRatio = gl_info->limits.texture_size;
5851 caps->MaxVertexW = 1.0f;
5853 caps->GuardBandLeft = 0.0f;
5854 caps->GuardBandTop = 0.0f;
5855 caps->GuardBandRight = 0.0f;
5856 caps->GuardBandBottom = 0.0f;
5858 caps->ExtentsAdjust = 0.0f;
5860 caps->StencilCaps = WINED3DSTENCILCAPS_DECRSAT |
5861 WINED3DSTENCILCAPS_INCRSAT |
5862 WINED3DSTENCILCAPS_INVERT |
5863 WINED3DSTENCILCAPS_KEEP |
5864 WINED3DSTENCILCAPS_REPLACE |
5865 WINED3DSTENCILCAPS_ZERO;
5866 if (gl_info->supported[EXT_STENCIL_WRAP])
5868 caps->StencilCaps |= WINED3DSTENCILCAPS_DECR |
5869 WINED3DSTENCILCAPS_INCR;
5871 if (gl_info->supported[WINED3D_GL_VERSION_2_0] || gl_info->supported[EXT_STENCIL_TWO_SIDE]
5872 || gl_info->supported[ATI_SEPARATE_STENCIL])
5874 caps->StencilCaps |= WINED3DSTENCILCAPS_TWOSIDED;
5877 caps->MaxAnisotropy = gl_info->limits.anisotropy;
5878 caps->MaxPointSize = gl_info->limits.pointsize_max;
5880 caps->MaxPrimitiveCount = 0x555555; /* Taken from an AMD Radeon HD 5700 (Evergreen) GPU. */
5881 caps->MaxVertexIndex = 0xffffff; /* Taken from an AMD Radeon HD 5700 (Evergreen) GPU. */
5882 caps->MaxStreams = MAX_STREAMS;
5883 caps->MaxStreamStride = 1024;
5885 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
5886 caps->DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET |
5887 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
5888 caps->MaxNpatchTessellationLevel = 0;
5889 caps->MasterAdapterOrdinal = 0;
5890 caps->AdapterOrdinalInGroup = 0;
5891 caps->NumberOfAdaptersInGroup = 1;
5893 caps->NumSimultaneousRTs = gl_info->limits.buffers;
5895 caps->StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT |
5896 WINED3DPTFILTERCAPS_MAGFPOINT |
5897 WINED3DPTFILTERCAPS_MINFLINEAR |
5898 WINED3DPTFILTERCAPS_MAGFLINEAR;
5899 caps->VertexTextureFilterCaps = 0;
5901 adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
5902 adapter->fragment_pipe->get_caps(&adapter->gl_info, &fragment_caps);
5903 adapter->vertex_pipe->vp_get_caps(&adapter->gl_info, &vertex_caps);
5905 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
5906 caps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps;
5908 caps->VertexShaderVersion = shader_caps.vs_version;
5909 caps->MaxVertexShaderConst = shader_caps.vs_uniform_count;
5911 caps->PixelShaderVersion = shader_caps.ps_version;
5912 caps->PixelShader1xMaxValue = shader_caps.ps_1x_max_value;
5914 caps->TextureOpCaps = fragment_caps.TextureOpCaps;
5915 caps->MaxTextureBlendStages = fragment_caps.MaxTextureBlendStages;
5916 caps->MaxSimultaneousTextures = fragment_caps.MaxSimultaneousTextures;
5918 caps->MaxUserClipPlanes = vertex_caps.max_user_clip_planes;
5919 caps->MaxActiveLights = vertex_caps.max_active_lights;
5920 caps->MaxVertexBlendMatrices = vertex_caps.max_vertex_blend_matrices;
5921 caps->MaxVertexBlendMatrixIndex = vertex_caps.max_vertex_blend_matrix_index;
5922 caps->VertexProcessingCaps = vertex_caps.vertex_processing_caps;
5923 caps->FVFCaps = vertex_caps.fvf_caps;
5924 caps->RasterCaps |= vertex_caps.raster_caps;
5926 /* The following caps are shader specific, but they are things we cannot detect, or which
5927 * are the same among all shader models. So to avoid code duplication set the shader version
5928 * specific, but otherwise constant caps here
5930 if (caps->VertexShaderVersion >= 3)
5932 /* Where possible set the caps based on OpenGL extensions and if they
5933 * aren't set (in case of software rendering) use the VS 3.0 from
5934 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
5935 * VS3.0 value. */
5936 caps->VS20Caps.caps = WINED3DVS20CAPS_PREDICATION;
5937 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
5938 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH;
5939 caps->VS20Caps.temp_count = max(32, adapter->gl_info.limits.arb_vs_temps);
5940 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
5941 caps->VS20Caps.static_flow_control_depth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH;
5943 caps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
5944 caps->MaxVertexShader30InstructionSlots = max(512, adapter->gl_info.limits.arb_vs_instructions);
5945 caps->VertexTextureFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT | WINED3DPTFILTERCAPS_MAGFPOINT;
5947 else if (caps->VertexShaderVersion == 2)
5949 caps->VS20Caps.caps = 0;
5950 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
5951 caps->VS20Caps.temp_count = max(12, adapter->gl_info.limits.arb_vs_temps);
5952 caps->VS20Caps.static_flow_control_depth = 1;
5954 caps->MaxVShaderInstructionsExecuted = 65535;
5955 caps->MaxVertexShader30InstructionSlots = 0;
5957 else
5958 { /* VS 1.x */
5959 caps->VS20Caps.caps = 0;
5960 caps->VS20Caps.dynamic_flow_control_depth = 0;
5961 caps->VS20Caps.temp_count = 0;
5962 caps->VS20Caps.static_flow_control_depth = 0;
5964 caps->MaxVShaderInstructionsExecuted = 0;
5965 caps->MaxVertexShader30InstructionSlots = 0;
5968 if (caps->PixelShaderVersion >= 3)
5970 /* Where possible set the caps based on OpenGL extensions and if they
5971 * aren't set (in case of software rendering) use the PS 3.0 from
5972 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
5973 * PS 3.0 value. */
5975 /* Caps is more or less undocumented on MSDN but it appears to be
5976 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
5977 * cards from Windows */
5978 caps->PS20Caps.caps = WINED3DPS20CAPS_ARBITRARYSWIZZLE |
5979 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS |
5980 WINED3DPS20CAPS_PREDICATION |
5981 WINED3DPS20CAPS_NODEPENDENTREADLIMIT |
5982 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT;
5983 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
5984 caps->PS20Caps.dynamic_flow_control_depth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH;
5985 caps->PS20Caps.temp_count = max(32, adapter->gl_info.limits.arb_ps_temps);
5986 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
5987 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH;
5988 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
5989 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS;
5991 caps->MaxPShaderInstructionsExecuted = 65535;
5992 caps->MaxPixelShader30InstructionSlots = max(WINED3DMIN30SHADERINSTRUCTIONS,
5993 adapter->gl_info.limits.arb_ps_instructions);
5995 else if(caps->PixelShaderVersion == 2)
5997 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
5998 caps->PS20Caps.caps = 0;
5999 caps->PS20Caps.dynamic_flow_control_depth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
6000 caps->PS20Caps.temp_count = max(12, adapter->gl_info.limits.arb_ps_temps);
6001 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minimum: 1 */
6002 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
6003 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS;
6005 caps->MaxPShaderInstructionsExecuted = 512; /* Minimum value, a GeforceFX uses 1024 */
6006 caps->MaxPixelShader30InstructionSlots = 0;
6008 else /* PS 1.x */
6010 caps->PS20Caps.caps = 0;
6011 caps->PS20Caps.dynamic_flow_control_depth = 0;
6012 caps->PS20Caps.temp_count = 0;
6013 caps->PS20Caps.static_flow_control_depth = 0;
6014 caps->PS20Caps.instruction_slot_count = 0;
6016 caps->MaxPShaderInstructionsExecuted = 0;
6017 caps->MaxPixelShader30InstructionSlots = 0;
6020 if (caps->VertexShaderVersion >= 2)
6022 /* OpenGL supports all the formats below, perhaps not always
6023 * without conversion, but it supports them.
6024 * Further GLSL doesn't seem to have an official unsigned type so
6025 * don't advertise it yet as I'm not sure how we handle it.
6026 * We might need to add some clamping in the shader engine to
6027 * support it.
6028 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
6029 caps->DeclTypes = WINED3DDTCAPS_UBYTE4 |
6030 WINED3DDTCAPS_UBYTE4N |
6031 WINED3DDTCAPS_SHORT2N |
6032 WINED3DDTCAPS_SHORT4N;
6033 if (gl_info->supported[ARB_HALF_FLOAT_VERTEX])
6035 caps->DeclTypes |= WINED3DDTCAPS_FLOAT16_2 |
6036 WINED3DDTCAPS_FLOAT16_4;
6039 else
6041 caps->DeclTypes = 0;
6044 /* Set DirectDraw helper Caps */
6045 ckey_caps = WINEDDCKEYCAPS_DESTBLT |
6046 WINEDDCKEYCAPS_SRCBLT;
6047 fx_caps = WINEDDFXCAPS_BLTALPHA |
6048 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT |
6049 WINEDDFXCAPS_BLTMIRRORUPDOWN |
6050 WINEDDFXCAPS_BLTROTATION90 |
6051 WINEDDFXCAPS_BLTSHRINKX |
6052 WINEDDFXCAPS_BLTSHRINKXN |
6053 WINEDDFXCAPS_BLTSHRINKY |
6054 WINEDDFXCAPS_BLTSHRINKYN |
6055 WINEDDFXCAPS_BLTSTRETCHX |
6056 WINEDDFXCAPS_BLTSTRETCHXN |
6057 WINEDDFXCAPS_BLTSTRETCHY |
6058 WINEDDFXCAPS_BLTSTRETCHYN;
6059 blit_caps = WINEDDCAPS_BLT |
6060 WINEDDCAPS_BLTCOLORFILL |
6061 WINEDDCAPS_BLTDEPTHFILL |
6062 WINEDDCAPS_BLTSTRETCH |
6063 WINEDDCAPS_CANBLTSYSMEM |
6064 WINEDDCAPS_CANCLIP |
6065 WINEDDCAPS_CANCLIPSTRETCHED |
6066 WINEDDCAPS_COLORKEY |
6067 WINEDDCAPS_COLORKEYHWASSIST;
6069 /* Fill the ddraw caps structure */
6070 caps->ddraw_caps.caps = WINEDDCAPS_GDI |
6071 WINEDDCAPS_PALETTE |
6072 blit_caps;
6073 caps->ddraw_caps.caps2 = WINEDDCAPS2_CERTIFIED |
6074 WINEDDCAPS2_NOPAGELOCKREQUIRED |
6075 WINEDDCAPS2_PRIMARYGAMMA |
6076 WINEDDCAPS2_WIDESURFACES |
6077 WINEDDCAPS2_CANRENDERWINDOWED;
6078 caps->ddraw_caps.color_key_caps = ckey_caps;
6079 caps->ddraw_caps.fx_caps = fx_caps;
6080 caps->ddraw_caps.svb_caps = blit_caps;
6081 caps->ddraw_caps.svb_color_key_caps = ckey_caps;
6082 caps->ddraw_caps.svb_fx_caps = fx_caps;
6083 caps->ddraw_caps.vsb_caps = blit_caps;
6084 caps->ddraw_caps.vsb_color_key_caps = ckey_caps;
6085 caps->ddraw_caps.vsb_fx_caps = fx_caps;
6086 caps->ddraw_caps.ssb_caps = blit_caps;
6087 caps->ddraw_caps.ssb_color_key_caps = ckey_caps;
6088 caps->ddraw_caps.ssb_fx_caps = fx_caps;
6090 caps->ddraw_caps.dds_caps = WINEDDSCAPS_ALPHA |
6091 WINEDDSCAPS_BACKBUFFER |
6092 WINEDDSCAPS_FLIP |
6093 WINEDDSCAPS_FRONTBUFFER |
6094 WINEDDSCAPS_OFFSCREENPLAIN |
6095 WINEDDSCAPS_PALETTE |
6096 WINEDDSCAPS_PRIMARYSURFACE |
6097 WINEDDSCAPS_SYSTEMMEMORY |
6098 WINEDDSCAPS_VIDEOMEMORY |
6099 WINEDDSCAPS_VISIBLE;
6101 if (!(wined3d->flags & WINED3D_NO3D))
6103 caps->ddraw_caps.dds_caps |= WINEDDSCAPS_3DDEVICE |
6104 WINEDDSCAPS_MIPMAP |
6105 WINEDDSCAPS_TEXTURE |
6106 WINEDDSCAPS_ZBUFFER;
6107 caps->ddraw_caps.caps |= WINEDDCAPS_3D;
6110 caps->shader_double_precision = d3d_info->shader_double_precision;
6112 return WINED3D_OK;
6115 HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, enum wined3d_device_type device_type,
6116 HWND focus_window, DWORD flags, BYTE surface_alignment, struct wined3d_device_parent *device_parent,
6117 struct wined3d_device **device)
6119 struct wined3d_device *object;
6120 HRESULT hr;
6122 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, surface_alignment %u, device_parent %p, device %p.\n",
6123 wined3d, adapter_idx, device_type, focus_window, flags, surface_alignment, device_parent, device);
6125 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
6126 * number and create a device without a 3D adapter for 2D only operation. */
6127 if (wined3d->adapter_count && adapter_idx >= wined3d->adapter_count)
6128 return WINED3DERR_INVALIDCALL;
6130 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
6131 if (!object)
6132 return E_OUTOFMEMORY;
6134 hr = device_init(object, wined3d, adapter_idx, device_type,
6135 focus_window, flags, surface_alignment, device_parent);
6136 if (FAILED(hr))
6138 WARN("Failed to initialize device, hr %#x.\n", hr);
6139 HeapFree(GetProcessHeap(), 0, object);
6140 return hr;
6143 TRACE("Created device %p.\n", object);
6144 *device = object;
6146 device_parent->ops->wined3d_device_created(device_parent, *device);
6148 return WINED3D_OK;
6151 static void WINE_GLAPI invalid_func(const void *data)
6153 ERR("Invalid vertex attribute function called.\n");
6154 DebugBreak();
6157 static void WINE_GLAPI invalid_texcoord_func(GLenum unit, const void *data)
6159 ERR("Invalid texcoord function called.\n");
6160 DebugBreak();
6163 static void WINE_GLAPI invalid_generic_attrib_func(GLuint idx, const void *data)
6165 ERR("Invalid attribute function called.\n");
6166 DebugBreak();
6169 /* Helper functions for providing vertex data to OpenGL. The arrays are
6170 * initialised based on the extension detection and are used in
6171 * draw_primitive_immediate_mode(). */
6172 static void WINE_GLAPI position_d3dcolor(const void *data)
6174 DWORD pos = *((const DWORD *)data);
6176 FIXME("Add a test for fixed function position from d3dcolor type.\n");
6177 context_get_current()->gl_info->gl_ops.gl.p_glVertex4s(D3DCOLOR_B_R(pos),
6178 D3DCOLOR_B_G(pos),
6179 D3DCOLOR_B_B(pos),
6180 D3DCOLOR_B_A(pos));
6183 static void WINE_GLAPI position_float4(const void *data)
6185 const GLfloat *pos = data;
6187 if (pos[3] != 0.0f && pos[3] != 1.0f)
6189 float w = 1.0f / pos[3];
6191 context_get_current()->gl_info->gl_ops.gl.p_glVertex4f(pos[0] * w, pos[1] * w, pos[2] * w, w);
6193 else
6195 context_get_current()->gl_info->gl_ops.gl.p_glVertex3fv(pos);
6199 static void WINE_GLAPI diffuse_d3dcolor(const void *data)
6201 DWORD diffuseColor = *((const DWORD *)data);
6203 context_get_current()->gl_info->gl_ops.gl.p_glColor4ub(D3DCOLOR_B_R(diffuseColor),
6204 D3DCOLOR_B_G(diffuseColor),
6205 D3DCOLOR_B_B(diffuseColor),
6206 D3DCOLOR_B_A(diffuseColor));
6209 static void WINE_GLAPI specular_d3dcolor(const void *data)
6211 DWORD specularColor = *((const DWORD *)data);
6212 GLubyte d[] =
6214 D3DCOLOR_B_R(specularColor),
6215 D3DCOLOR_B_G(specularColor),
6216 D3DCOLOR_B_B(specularColor)
6219 context_get_current()->gl_info->gl_ops.ext.p_glSecondaryColor3ubvEXT(d);
6222 static void WINE_GLAPI warn_no_specular_func(const void *data)
6224 WARN("GL_EXT_secondary_color not supported.\n");
6227 static void WINE_GLAPI generic_d3dcolor(GLuint idx, const void *data)
6229 DWORD color = *((const DWORD *)data);
6231 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4Nub(idx,
6232 D3DCOLOR_B_R(color), D3DCOLOR_B_G(color),
6233 D3DCOLOR_B_B(color), D3DCOLOR_B_A(color));
6236 static void WINE_GLAPI generic_short2n(GLuint idx, const void *data)
6238 const GLshort s[] = {((const GLshort *)data)[0], ((const GLshort *)data)[1], 0, 1};
6240 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4Nsv(idx, s);
6243 static void WINE_GLAPI generic_ushort2n(GLuint idx, const void *data)
6245 const GLushort s[] = {((const GLushort *)data)[0], ((const GLushort *)data)[1], 0, 1};
6247 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4Nusv(idx, s);
6250 static void WINE_GLAPI generic_float16_2(GLuint idx, const void *data)
6252 float x = float_16_to_32(((const unsigned short *)data) + 0);
6253 float y = float_16_to_32(((const unsigned short *)data) + 1);
6255 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib2f(idx, x, y);
6258 static void WINE_GLAPI generic_float16_4(GLuint idx, const void *data)
6260 float x = float_16_to_32(((const unsigned short *)data) + 0);
6261 float y = float_16_to_32(((const unsigned short *)data) + 1);
6262 float z = float_16_to_32(((const unsigned short *)data) + 2);
6263 float w = float_16_to_32(((const unsigned short *)data) + 3);
6265 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4f(idx, x, y, z, w);
6268 static void wined3d_adapter_init_ffp_attrib_ops(struct wined3d_adapter *adapter)
6270 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
6271 struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
6272 struct wined3d_ffp_attrib_ops *ops = &d3d_info->ffp_attrib_ops;
6273 unsigned int i;
6275 for (i = 0; i < WINED3D_FFP_EMIT_COUNT; ++i)
6277 ops->position[i] = invalid_func;
6278 ops->diffuse[i] = invalid_func;
6279 ops->specular[i] = invalid_func;
6280 ops->normal[i] = invalid_func;
6281 ops->texcoord[i] = invalid_texcoord_func;
6282 ops->generic[i] = invalid_generic_attrib_func;
6285 ops->position[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glVertex3fv;
6286 if (!d3d_info->xyzrhw)
6287 ops->position[WINED3D_FFP_EMIT_FLOAT4] = position_float4;
6288 else
6289 ops->position[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glVertex4fv;
6290 ops->position[WINED3D_FFP_EMIT_D3DCOLOR] = position_d3dcolor;
6291 ops->position[WINED3D_FFP_EMIT_SHORT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glVertex2sv;
6293 ops->diffuse[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor3fv;
6294 ops->diffuse[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4fv;
6295 ops->diffuse[WINED3D_FFP_EMIT_D3DCOLOR] = diffuse_d3dcolor;
6296 ops->diffuse[WINED3D_FFP_EMIT_UBYTE4N] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4ubv;
6297 ops->diffuse[WINED3D_FFP_EMIT_SHORT4N] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4sv;
6298 ops->diffuse[WINED3D_FFP_EMIT_USHORT4N] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4usv;
6300 /* No 4 component entry points here. */
6301 if (gl_info->supported[EXT_SECONDARY_COLOR])
6302 ops->specular[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)GL_EXTCALL(glSecondaryColor3fvEXT);
6303 else
6304 ops->specular[WINED3D_FFP_EMIT_FLOAT3] = warn_no_specular_func;
6305 if (gl_info->supported[EXT_SECONDARY_COLOR])
6306 ops->specular[WINED3D_FFP_EMIT_D3DCOLOR] = specular_d3dcolor;
6307 else
6308 ops->specular[WINED3D_FFP_EMIT_D3DCOLOR] = warn_no_specular_func;
6310 /* Only 3 component entry points here. Test how others behave. Float4
6311 * normals are used by one of our tests, trying to pass it to the pixel
6312 * shader, which fails on Windows. */
6313 ops->normal[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glNormal3fv;
6314 /* Just ignore the 4th value. */
6315 ops->normal[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glNormal3fv;
6317 ops->texcoord[WINED3D_FFP_EMIT_FLOAT1] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord1fvARB;
6318 ops->texcoord[WINED3D_FFP_EMIT_FLOAT2] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord2fvARB;
6319 ops->texcoord[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord3fvARB;
6320 ops->texcoord[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord4fvARB;
6321 ops->texcoord[WINED3D_FFP_EMIT_SHORT2] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord2svARB;
6322 ops->texcoord[WINED3D_FFP_EMIT_SHORT4] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord4svARB;
6323 if (gl_info->supported[NV_HALF_FLOAT])
6325 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT. */
6326 ops->texcoord[WINED3D_FFP_EMIT_FLOAT16_2] =
6327 (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord2hvNV;
6328 ops->texcoord[WINED3D_FFP_EMIT_FLOAT16_4] =
6329 (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord4hvNV;
6332 ops->generic[WINED3D_FFP_EMIT_FLOAT1] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib1fv;
6333 ops->generic[WINED3D_FFP_EMIT_FLOAT2] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2fv;
6334 ops->generic[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib3fv;
6335 ops->generic[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4fv;
6336 if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
6337 ops->generic[WINED3D_FFP_EMIT_D3DCOLOR] = generic_d3dcolor;
6338 else
6339 ops->generic[WINED3D_FFP_EMIT_D3DCOLOR] =
6340 (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nubv;
6341 ops->generic[WINED3D_FFP_EMIT_UBYTE4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4ubv;
6342 ops->generic[WINED3D_FFP_EMIT_SHORT2] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2sv;
6343 ops->generic[WINED3D_FFP_EMIT_SHORT4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4sv;
6344 ops->generic[WINED3D_FFP_EMIT_UBYTE4N] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nubv;
6345 ops->generic[WINED3D_FFP_EMIT_SHORT2N] = generic_short2n;
6346 ops->generic[WINED3D_FFP_EMIT_SHORT4N] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nsv;
6347 ops->generic[WINED3D_FFP_EMIT_USHORT2N] = generic_ushort2n;
6348 ops->generic[WINED3D_FFP_EMIT_USHORT4N] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nusv;
6349 if (gl_info->supported[NV_HALF_FLOAT] && gl_info->supported[NV_VERTEX_PROGRAM])
6351 ops->generic[WINED3D_FFP_EMIT_FLOAT16_2] =
6352 (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2hvNV;
6353 ops->generic[WINED3D_FFP_EMIT_FLOAT16_4] =
6354 (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4hvNV;
6356 else
6358 ops->generic[WINED3D_FFP_EMIT_FLOAT16_2] = generic_float16_2;
6359 ops->generic[WINED3D_FFP_EMIT_FLOAT16_4] = generic_float16_4;
6363 static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter *adapter, HDC dc)
6365 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
6366 int i;
6368 if (gl_info->supported[WGL_ARB_PIXEL_FORMAT])
6370 UINT attrib_count = 0;
6371 GLint cfg_count;
6372 int attribs[11];
6373 int values[11];
6374 int attribute;
6376 attribute = WGL_NUMBER_PIXEL_FORMATS_ARB;
6377 GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, 0, 0, 1, &attribute, &cfg_count));
6379 adapter->cfgs = wined3d_calloc(cfg_count, sizeof(*adapter->cfgs));
6380 attribs[attrib_count++] = WGL_RED_BITS_ARB;
6381 attribs[attrib_count++] = WGL_GREEN_BITS_ARB;
6382 attribs[attrib_count++] = WGL_BLUE_BITS_ARB;
6383 attribs[attrib_count++] = WGL_ALPHA_BITS_ARB;
6384 attribs[attrib_count++] = WGL_COLOR_BITS_ARB;
6385 attribs[attrib_count++] = WGL_DEPTH_BITS_ARB;
6386 attribs[attrib_count++] = WGL_STENCIL_BITS_ARB;
6387 attribs[attrib_count++] = WGL_DRAW_TO_WINDOW_ARB;
6388 attribs[attrib_count++] = WGL_PIXEL_TYPE_ARB;
6389 attribs[attrib_count++] = WGL_DOUBLE_BUFFER_ARB;
6390 attribs[attrib_count++] = WGL_AUX_BUFFERS_ARB;
6392 for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
6394 struct wined3d_pixel_format *cfg = &adapter->cfgs[adapter->cfg_count];
6395 int format_id = i + 1;
6397 if (!GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, format_id, 0, attrib_count, attribs, values)))
6398 continue;
6400 cfg->iPixelFormat = format_id;
6401 cfg->redSize = values[0];
6402 cfg->greenSize = values[1];
6403 cfg->blueSize = values[2];
6404 cfg->alphaSize = values[3];
6405 cfg->colorSize = values[4];
6406 cfg->depthSize = values[5];
6407 cfg->stencilSize = values[6];
6408 cfg->windowDrawable = values[7];
6409 cfg->iPixelType = values[8];
6410 cfg->doubleBuffer = values[9];
6411 cfg->auxBuffers = values[10];
6413 cfg->numSamples = 0;
6414 /* Check multisample support. */
6415 if (gl_info->supported[ARB_MULTISAMPLE])
6417 int attribs[2] = {WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB};
6418 int values[2];
6420 if (GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, format_id, 0, 2, attribs, values)))
6422 /* values[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether
6423 * multisampling is supported. values[1] = number of
6424 * multisample buffers. */
6425 if (values[0])
6426 cfg->numSamples = values[1];
6430 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
6431 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
6432 cfg->iPixelFormat, cfg->iPixelType, cfg->doubleBuffer,
6433 cfg->redSize, cfg->greenSize, cfg->blueSize, cfg->alphaSize,
6434 cfg->depthSize, cfg->stencilSize, cfg->numSamples, cfg->windowDrawable);
6436 ++adapter->cfg_count;
6439 else
6441 int cfg_count;
6443 cfg_count = DescribePixelFormat(dc, 0, 0, 0);
6444 adapter->cfgs = wined3d_calloc(cfg_count, sizeof(*adapter->cfgs));
6446 for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
6448 struct wined3d_pixel_format *cfg = &adapter->cfgs[adapter->cfg_count];
6449 PIXELFORMATDESCRIPTOR pfd;
6450 int format_id = i + 1;
6452 if (!DescribePixelFormat(dc, format_id, sizeof(pfd), &pfd))
6453 continue;
6455 /* We only want HW acceleration using an OpenGL ICD driver.
6456 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering.
6457 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD
6458 * driver (e.g. 3dfx minigl). */
6459 if (pfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED))
6461 TRACE("Skipping format %d because it isn't ICD accelerated.\n", format_id);
6462 continue;
6465 cfg->iPixelFormat = format_id;
6466 cfg->redSize = pfd.cRedBits;
6467 cfg->greenSize = pfd.cGreenBits;
6468 cfg->blueSize = pfd.cBlueBits;
6469 cfg->alphaSize = pfd.cAlphaBits;
6470 cfg->colorSize = pfd.cColorBits;
6471 cfg->depthSize = pfd.cDepthBits;
6472 cfg->stencilSize = pfd.cStencilBits;
6473 cfg->windowDrawable = (pfd.dwFlags & PFD_DRAW_TO_WINDOW) ? 1 : 0;
6474 cfg->iPixelType = (pfd.iPixelType == PFD_TYPE_RGBA) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB;
6475 cfg->doubleBuffer = (pfd.dwFlags & PFD_DOUBLEBUFFER) ? 1 : 0;
6476 cfg->auxBuffers = pfd.cAuxBuffers;
6477 cfg->numSamples = 0;
6479 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
6480 "depth=%d, stencil=%d, windowDrawable=%d\n",
6481 cfg->iPixelFormat, cfg->iPixelType, cfg->doubleBuffer,
6482 cfg->redSize, cfg->greenSize, cfg->blueSize, cfg->alphaSize,
6483 cfg->depthSize, cfg->stencilSize, cfg->windowDrawable);
6485 ++adapter->cfg_count;
6490 static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal, DWORD wined3d_creation_flags)
6492 static const DWORD supported_gl_versions[] =
6494 MAKEDWORD_VERSION(3, 2),
6495 MAKEDWORD_VERSION(1, 0),
6497 struct wined3d_gl_info *gl_info = &adapter->gl_info;
6498 struct wined3d_caps_gl_ctx caps_gl_ctx = {0};
6499 unsigned int i;
6500 DISPLAY_DEVICEW display_device;
6502 TRACE("adapter %p, ordinal %u.\n", adapter, ordinal);
6504 adapter->ordinal = ordinal;
6506 /* Dynamically load all GL core functions */
6507 #ifdef USE_WIN32_OPENGL
6509 HMODULE mod_gl = GetModuleHandleA("opengl32.dll");
6510 #define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
6511 ALL_WGL_FUNCS
6512 #undef USE_GL_FUNC
6513 gl_info->gl_ops.wgl.p_wglSwapBuffers = (void *)GetProcAddress(mod_gl, "wglSwapBuffers");
6514 gl_info->gl_ops.wgl.p_wglGetPixelFormat = (void *)GetProcAddress(mod_gl, "wglGetPixelFormat");
6516 #else
6517 /* To bypass the opengl32 thunks retrieve functions from the WGL driver instead of opengl32 */
6519 HDC hdc = GetDC( 0 );
6520 const struct opengl_funcs *wgl_driver = __wine_get_wgl_driver( hdc, WINE_WGL_DRIVER_VERSION );
6521 ReleaseDC( 0, hdc );
6522 if (!wgl_driver || wgl_driver == (void *)-1) return FALSE;
6523 gl_info->gl_ops.wgl = wgl_driver->wgl;
6524 gl_info->gl_ops.gl = wgl_driver->gl;
6526 #endif
6528 glEnableWINE = gl_info->gl_ops.gl.p_glEnable;
6529 glDisableWINE = gl_info->gl_ops.gl.p_glDisable;
6531 if (!AllocateLocallyUniqueId(&adapter->luid))
6533 ERR("Failed to set adapter LUID (%#x).\n", GetLastError());
6534 return FALSE;
6536 TRACE("Allocated LUID %08x:%08x for adapter %p.\n",
6537 adapter->luid.HighPart, adapter->luid.LowPart, adapter);
6539 if (!wined3d_caps_gl_ctx_create(adapter, &caps_gl_ctx))
6541 ERR("Failed to get a GL context for adapter %p.\n", adapter);
6542 return FALSE;
6545 for (i = 0; i < ARRAY_SIZE(supported_gl_versions); ++i)
6547 if (supported_gl_versions[i] <= wined3d_settings.max_gl_version)
6548 break;
6550 if (i == ARRAY_SIZE(supported_gl_versions))
6552 ERR_(winediag)("Requested invalid GL version %u.%u.\n",
6553 wined3d_settings.max_gl_version >> 16, wined3d_settings.max_gl_version & 0xffff);
6554 i = ARRAY_SIZE(supported_gl_versions) - 1;
6557 for (; i < ARRAY_SIZE(supported_gl_versions); ++i)
6559 gl_info->selected_gl_version = supported_gl_versions[i];
6561 if (wined3d_caps_gl_ctx_create_attribs(&caps_gl_ctx, gl_info))
6562 break;
6564 WARN("Couldn't create an OpenGL %u.%u context, trying fallback to a lower version.\n",
6565 supported_gl_versions[i] >> 16, supported_gl_versions[i] & 0xffff);
6568 if (!wined3d_adapter_init_gl_caps(adapter, &caps_gl_ctx, wined3d_creation_flags))
6570 ERR("Failed to initialize GL caps for adapter %p.\n", adapter);
6571 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
6572 return FALSE;
6575 if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
6576 ERR_(winediag)("You are using the backbuffer for offscreen rendering. "
6577 "This is unsupported, and will be removed in a future version.\n");
6579 wined3d_adapter_init_fb_cfgs(adapter, caps_gl_ctx.dc);
6580 /* We haven't found any suitable formats. This should only happen in
6581 * case of GDI software rendering, which is pretty useless anyway. */
6582 if (!adapter->cfg_count)
6584 WARN("No suitable pixel formats found.\n");
6585 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
6586 HeapFree(GetProcessHeap(), 0, adapter->cfgs);
6587 return FALSE;
6590 if (!wined3d_adapter_init_format_info(adapter, &caps_gl_ctx))
6592 ERR("Failed to initialize GL format info.\n");
6593 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
6594 HeapFree(GetProcessHeap(), 0, adapter->cfgs);
6595 return FALSE;
6598 gl_info->fixed_polyoffset_scale = wined3d_adapter_find_polyoffset_scale(&caps_gl_ctx, GL_DEPTH_COMPONENT);
6599 if (gl_info->supported[ARB_DEPTH_BUFFER_FLOAT])
6600 gl_info->float_polyoffset_scale = wined3d_adapter_find_polyoffset_scale(&caps_gl_ctx, GL_DEPTH32F_STENCIL8);
6602 adapter->vram_bytes = adapter->driver_info.vram_bytes;
6603 adapter->vram_bytes_used = 0;
6604 TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes));
6606 display_device.cb = sizeof(display_device);
6607 EnumDisplayDevicesW(NULL, ordinal, &display_device, 0);
6608 TRACE("DeviceName: %s\n", debugstr_w(display_device.DeviceName));
6609 strcpyW(adapter->DeviceName, display_device.DeviceName);
6611 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
6613 wined3d_adapter_init_ffp_attrib_ops(adapter);
6615 return TRUE;
6618 static BOOL wined3d_adapter_init_nogl(struct wined3d_adapter *adapter, UINT ordinal)
6620 DISPLAY_DEVICEW display_device;
6622 memset(adapter, 0, sizeof(*adapter));
6623 adapter->ordinal = ordinal;
6625 adapter->driver_info.name = "Display";
6626 adapter->driver_info.description = "WineD3D DirectDraw Emulation";
6627 if (wined3d_settings.emulated_textureram)
6628 adapter->vram_bytes = wined3d_settings.emulated_textureram;
6629 else
6630 adapter->vram_bytes = 128 * 1024 * 1024;
6632 if (!wined3d_adapter_init_format_info(adapter, NULL))
6633 return FALSE;
6635 adapter->vertex_pipe = &none_vertex_pipe;
6636 adapter->fragment_pipe = &none_fragment_pipe;
6637 adapter->shader_backend = &none_shader_backend;
6639 display_device.cb = sizeof(display_device);
6640 EnumDisplayDevicesW(NULL, ordinal, &display_device, 0);
6641 TRACE("DeviceName: %s\n", debugstr_w(display_device.DeviceName));
6642 strcpyW(adapter->DeviceName, display_device.DeviceName);
6644 return TRUE;
6647 static void STDMETHODCALLTYPE wined3d_null_wined3d_object_destroyed(void *parent) {}
6649 const struct wined3d_parent_ops wined3d_null_parent_ops =
6651 wined3d_null_wined3d_object_destroyed,
6654 HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags)
6656 BOOL ret;
6658 wined3d->ref = 1;
6659 wined3d->flags = flags;
6661 TRACE("Initializing adapters.\n");
6663 if (flags & WINED3D_NO3D)
6664 ret = wined3d_adapter_init_nogl(&wined3d->adapters[0], 0);
6665 else
6666 ret = wined3d_adapter_init(&wined3d->adapters[0], 0, flags);
6667 if (!ret)
6669 WARN("Failed to initialize adapter.\n");
6670 return E_FAIL;
6672 wined3d->adapter_count = 1;
6674 return WINED3D_OK;