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