2 * Copyright 2002-2004 Jason Edmeades
3 * Copyright 2003-2004 Raphael Junqueira
4 * Copyright 2004 Christian Costa
5 * Copyright 2005 Oliver Stieber
6 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
7 * Copyright 2009-2011 Henri Verbeet for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/port.h"
29 #include "wined3d_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
33 WINE_DECLARE_DEBUG_CHANNEL(d3d_perf
);
35 #define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
36 #define DEFAULT_REFRESH_RATE 0
38 /* The driver names reflect the lowest GPU supported
39 * by a certain driver, so DRIVER_AMD_R300 supports
40 * R3xx, R4xx and R5xx GPUs. */
41 enum wined3d_display_driver
43 DRIVER_AMD_RAGE_128PRO
,
52 DRIVER_NVIDIA_GEFORCE2MX
,
53 DRIVER_NVIDIA_GEFORCEFX
,
54 DRIVER_NVIDIA_GEFORCE6
,
58 enum wined3d_driver_model
66 enum wined3d_gl_vendor
76 /* The d3d device ID */
77 static const GUID IID_D3DDEVICE_D3DUID
= { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
79 /* Extension detection */
80 struct wined3d_extension_map
82 const char *extension_string
;
83 enum wined3d_gl_extension extension
;
86 static const struct wined3d_extension_map gl_extension_map
[] =
89 {"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE
},
90 {"GL_APPLE_fence", APPLE_FENCE
},
91 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS
},
92 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE
},
93 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422
},
96 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT
},
97 {"GL_ARB_debug_output", ARB_DEBUG_OUTPUT
},
98 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT
},
99 {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP
},
100 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE
},
101 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS
},
102 {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX
},
103 {"GL_ARB_draw_instanced", ARB_DRAW_INSTANCED
},
104 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM
},
105 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER
},
106 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT
},
107 {"GL_ARB_framebuffer_sRGB", ARB_FRAMEBUFFER_SRGB
},
108 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4
},
109 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL
},
110 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX
},
111 {"GL_ARB_instanced_arrays", ARB_INSTANCED_ARRAYS
, },
112 {"GL_ARB_internalformat_query2", ARB_INTERNALFORMAT_QUERY2
, },
113 {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT
},
114 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE
},
115 {"GL_ARB_multisample", ARB_MULTISAMPLE
}, /* needs GLX_ARB_MULTISAMPLE as well */
116 {"GL_ARB_multitexture", ARB_MULTITEXTURE
},
117 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY
},
118 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT
},
119 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS
},
120 {"GL_ARB_point_sprite", ARB_POINT_SPRITE
},
121 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX
},
122 {"GL_ARB_shader_bit_encoding", ARB_SHADER_BIT_ENCODING
},
123 {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS
},
124 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD
},
125 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100
},
126 {"GL_ARB_shadow", ARB_SHADOW
},
127 {"GL_ARB_sync", ARB_SYNC
},
128 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP
},
129 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION
},
130 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC
},
131 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP
},
132 {"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD
},
133 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE
},
134 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3
},
135 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT
},
136 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT
},
137 {"GL_ARB_texture_mirror_clamp_to_edge", ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
},
138 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO
},
139 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE
},
140 {"GL_ARB_texture_rg", ARB_TEXTURE_RG
},
141 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA
},
142 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND
},
143 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT
},
144 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM
},
145 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER
},
148 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER
},
149 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL
},
150 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC
},
151 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3
},
152 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE
},
155 {"GL_EXT_blend_color", EXT_BLEND_COLOR
},
156 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE
},
157 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE
},
158 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX
},
159 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT
},
160 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST
},
161 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2
},
162 {"GL_EXT_fog_coord", EXT_FOG_COORD
},
163 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT
},
164 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE
},
165 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT
},
166 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS
},
167 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4
},
168 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL
},
169 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS
},
170 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX
},
171 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR
},
172 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE
},
173 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP
},
174 {"GL_EXT_texture3D", EXT_TEXTURE3D
},
175 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC
},
176 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC
},
177 {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD
},
178 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE
},
179 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3
},
180 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC
},
181 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS
},
182 {"GL_EXT_texture_mirror_clamp", EXT_TEXTURE_MIRROR_CLAMP
},
183 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB
},
184 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE
},
185 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA
},
188 {"GL_NV_depth_clamp", NV_DEPTH_CLAMP
},
189 {"GL_NV_fence", NV_FENCE
},
190 {"GL_NV_fog_distance", NV_FOG_DISTANCE
},
191 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM
},
192 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2
},
193 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION
},
194 {"GL_NV_half_float", NV_HALF_FLOAT
},
195 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT
},
196 {"GL_NV_point_sprite", NV_POINT_SPRITE
},
197 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS
},
198 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2
},
199 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION
},
200 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4
},
201 {"GL_NV_texture_shader", NV_TEXTURE_SHADER
},
202 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2
},
203 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM
},
204 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1
},
205 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2
},
206 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION
},
207 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3
},
210 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP
},
213 static const struct wined3d_extension_map wgl_extension_map
[] =
215 {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT
},
216 {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL
},
217 {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH
},
220 /**********************************************************
221 * Utility functions follow
222 **********************************************************/
224 const struct min_lookup minMipLookup
[] =
226 /* NONE POINT LINEAR */
227 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
228 {{GL_NEAREST
, GL_NEAREST_MIPMAP_NEAREST
, GL_NEAREST_MIPMAP_LINEAR
}}, /* POINT*/
229 {{GL_LINEAR
, GL_LINEAR_MIPMAP_NEAREST
, GL_LINEAR_MIPMAP_LINEAR
}}, /* LINEAR */
232 const struct min_lookup minMipLookup_noFilter
[] =
234 /* NONE POINT LINEAR */
235 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
236 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
237 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* LINEAR */
240 const struct min_lookup minMipLookup_noMip
[] =
242 /* NONE POINT LINEAR */
243 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* NONE */
244 {{GL_NEAREST
, GL_NEAREST
, GL_NEAREST
}}, /* POINT */
245 {{GL_LINEAR
, GL_LINEAR
, GL_LINEAR
}}, /* LINEAR */
248 const GLenum magLookup
[] =
250 /* NONE POINT LINEAR */
251 GL_NEAREST
, GL_NEAREST
, GL_LINEAR
,
254 const GLenum magLookup_noFilter
[] =
256 /* NONE POINT LINEAR */
257 GL_NEAREST
, GL_NEAREST
, GL_NEAREST
,
260 struct wined3d_caps_gl_ctx
266 HGLRC restore_gl_ctx
;
269 static void wined3d_caps_gl_ctx_destroy(const struct wined3d_caps_gl_ctx
*ctx
)
271 TRACE("Destroying caps GL context.\n");
273 if (!wglMakeCurrent(NULL
, NULL
))
274 ERR("Failed to disable caps GL context.\n");
276 if (!wglDeleteContext(ctx
->gl_ctx
))
278 DWORD err
= GetLastError();
279 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx
->gl_ctx
, err
);
282 wined3d_release_dc(ctx
->wnd
, ctx
->dc
);
283 DestroyWindow(ctx
->wnd
);
285 if (ctx
->restore_gl_ctx
&& !wglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
286 ERR("Failed to restore previous GL context.\n");
289 static void wined3d_caps_gl_ctx_create_attribs(struct wined3d_caps_gl_ctx
*caps_gl_ctx
,
290 struct wined3d_gl_info
*gl_info
, const GLint
*ctx_attribs
)
294 if (!(gl_info
->p_wglCreateContextAttribsARB
= (void *)wglGetProcAddress("wglCreateContextAttribsARB")))
297 if (!(new_ctx
= gl_info
->p_wglCreateContextAttribsARB(caps_gl_ctx
->dc
, NULL
, ctx_attribs
)))
299 ERR("Failed to create a context using wglCreateContextAttribsARB(), last error %#x.\n", GetLastError());
300 gl_info
->p_wglCreateContextAttribsARB
= NULL
;
304 if (!wglMakeCurrent(caps_gl_ctx
->dc
, new_ctx
))
306 ERR("Failed to make new context current, last error %#x.\n", GetLastError());
307 if (!wglDeleteContext(new_ctx
))
308 ERR("Failed to delete new context, last error %#x.\n", GetLastError());
309 gl_info
->p_wglCreateContextAttribsARB
= NULL
;
313 if (!wglDeleteContext(caps_gl_ctx
->gl_ctx
))
314 ERR("Failed to delete old context, last error %#x.\n", GetLastError());
315 caps_gl_ctx
->gl_ctx
= new_ctx
;
318 static BOOL
wined3d_caps_gl_ctx_create(struct wined3d_caps_gl_ctx
*ctx
)
320 PIXELFORMATDESCRIPTOR pfd
;
323 TRACE("getting context...\n");
325 ctx
->restore_dc
= wglGetCurrentDC();
326 ctx
->restore_gl_ctx
= wglGetCurrentContext();
328 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
329 ctx
->wnd
= CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME
, "WineD3D fake window",
330 WS_OVERLAPPEDWINDOW
, 10, 10, 10, 10, NULL
, NULL
, NULL
, NULL
);
333 ERR("Failed to create a window.\n");
337 ctx
->dc
= GetDC(ctx
->wnd
);
340 ERR("Failed to get a DC.\n");
344 /* PixelFormat selection */
345 ZeroMemory(&pfd
, sizeof(pfd
));
346 pfd
.nSize
= sizeof(pfd
);
348 pfd
.dwFlags
= PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER
| PFD_DRAW_TO_WINDOW
; /* PFD_GENERIC_ACCELERATED */
349 pfd
.iPixelType
= PFD_TYPE_RGBA
;
351 pfd
.iLayerType
= PFD_MAIN_PLANE
;
353 if (!(iPixelFormat
= ChoosePixelFormat(ctx
->dc
, &pfd
)))
355 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
356 ERR("Failed to find a suitable pixel format.\n");
359 DescribePixelFormat(ctx
->dc
, iPixelFormat
, sizeof(pfd
), &pfd
);
360 SetPixelFormat(ctx
->dc
, iPixelFormat
, &pfd
);
362 /* Create a GL context. */
363 if (!(ctx
->gl_ctx
= wglCreateContext(ctx
->dc
)))
365 WARN("Failed to create default context for capabilities initialization.\n");
369 /* Make it the current GL context. */
370 if (!wglMakeCurrent(ctx
->dc
, ctx
->gl_ctx
))
372 ERR("Failed to make caps GL context current.\n");
379 if (ctx
->gl_ctx
) wglDeleteContext(ctx
->gl_ctx
);
381 if (ctx
->dc
) ReleaseDC(ctx
->wnd
, ctx
->dc
);
383 if (ctx
->wnd
) DestroyWindow(ctx
->wnd
);
385 if (ctx
->restore_gl_ctx
&& !wglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
386 ERR("Failed to restore previous GL context.\n");
391 /* Adjust the amount of used texture memory */
392 unsigned int adapter_adjust_memory(struct wined3d_adapter
*adapter
, int amount
)
394 adapter
->UsedTextureRam
+= amount
;
395 TRACE("Adjusted adapter memory by %d to %d.\n", amount
, adapter
->UsedTextureRam
);
396 return adapter
->UsedTextureRam
;
399 static void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
)
401 HeapFree(GetProcessHeap(), 0, adapter
->gl_info
.formats
);
402 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
405 ULONG CDECL
wined3d_incref(struct wined3d
*wined3d
)
407 ULONG refcount
= InterlockedIncrement(&wined3d
->ref
);
409 TRACE("%p increasing refcount to %u.\n", wined3d
, refcount
);
414 ULONG CDECL
wined3d_decref(struct wined3d
*wined3d
)
416 ULONG refcount
= InterlockedDecrement(&wined3d
->ref
);
418 TRACE("%p decreasing refcount to %u.\n", wined3d
, refcount
);
424 for (i
= 0; i
< wined3d
->adapter_count
; ++i
)
426 wined3d_adapter_cleanup(&wined3d
->adapters
[i
]);
428 HeapFree(GetProcessHeap(), 0, wined3d
);
434 /* Context activation is done by the caller. */
435 static BOOL
test_arb_vs_offset_limit(const struct wined3d_gl_info
*gl_info
)
439 const char *testcode
=
441 "PARAM C[66] = { program.env[0..65] };\n"
443 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
444 "ARL A0.x, zero.x;\n"
445 "MOV result.position, C[A0.x + 65];\n"
448 while (gl_info
->gl_ops
.gl
.p_glGetError());
449 GL_EXTCALL(glGenProgramsARB(1, &prog
));
451 ERR("Failed to create an ARB offset limit test program\n");
453 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
454 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
455 strlen(testcode
), testcode
));
456 if (gl_info
->gl_ops
.gl
.p_glGetError())
458 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
459 TRACE("error: %s\n", debugstr_a((const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
461 } else TRACE("OpenGL implementation allows offsets > 63\n");
463 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
464 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
465 checkGLcall("ARB vp offset limit test cleanup");
470 static BOOL
match_amd_r300_to_500(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
471 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
473 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
474 if (device
== CARD_AMD_RADEON_9500
) return TRUE
;
475 if (device
== CARD_AMD_RADEON_X700
) return TRUE
;
476 if (device
== CARD_AMD_RADEON_X1600
) return TRUE
;
480 static BOOL
match_geforce5(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
481 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
483 if (card_vendor
== HW_VENDOR_NVIDIA
)
485 if (device
== CARD_NVIDIA_GEFORCEFX_5200
||
486 device
== CARD_NVIDIA_GEFORCEFX_5600
||
487 device
== CARD_NVIDIA_GEFORCEFX_5800
)
495 static BOOL
match_apple(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
496 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
498 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
499 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
500 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
502 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
503 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
504 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
505 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
506 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
507 * the chance that other implementations support them is rather small since Win32 QuickTime uses
508 * DirectDraw, not OpenGL.
510 * This test has been moved into wined3d_guess_gl_vendor()
512 if (gl_vendor
== GL_VENDOR_APPLE
)
519 /* Context activation is done by the caller. */
520 static void test_pbo_functionality(struct wined3d_gl_info
*gl_info
)
522 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
523 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
524 * all the texture. This function detects this bug by its symptom and disables PBOs
527 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
528 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
529 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
530 * read back is compared to the original. If they are equal PBOs are assumed to work,
531 * otherwise the PBO extension is disabled. */
533 static const unsigned int pattern
[] =
535 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
536 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
537 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
538 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
540 unsigned int check
[sizeof(pattern
) / sizeof(pattern
[0])];
542 /* No PBO -> No point in testing them. */
543 if (!gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
]) return;
545 while (gl_info
->gl_ops
.gl
.p_glGetError());
546 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &texture
);
547 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, texture
);
549 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAX_LEVEL
, 0);
550 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);
551 checkGLcall("Specifying the PBO test texture");
553 GL_EXTCALL(glGenBuffersARB(1, &pbo
));
554 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, pbo
));
555 GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB
, sizeof(pattern
), pattern
, GL_STREAM_DRAW_ARB
));
556 checkGLcall("Specifying the PBO test pbo");
558 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
);
559 checkGLcall("Loading the PBO test texture");
561 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB
, 0));
563 gl_info
->gl_ops
.gl
.p_glFinish(); /* just to be sure */
565 memset(check
, 0, sizeof(check
));
566 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, check
);
567 checkGLcall("Reading back the PBO test texture");
569 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &texture
);
570 GL_EXTCALL(glDeleteBuffersARB(1, &pbo
));
571 checkGLcall("PBO test cleanup");
573 if (memcmp(check
, pattern
, sizeof(check
)))
575 WARN_(d3d_perf
)("PBO test failed, read back data doesn't match original.\n"
576 "Disabling PBOs. This may result in slower performance.\n");
577 gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
] = FALSE
;
581 TRACE("PBO test successful.\n");
585 static BOOL
match_apple_intel(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
586 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
588 return (card_vendor
== HW_VENDOR_INTEL
) && (gl_vendor
== GL_VENDOR_APPLE
);
591 static BOOL
match_apple_nonr500ati(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
592 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
594 if (gl_vendor
!= GL_VENDOR_APPLE
) return FALSE
;
595 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
596 if (device
== CARD_AMD_RADEON_X1600
) return FALSE
;
600 static BOOL
match_dx10_capable(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
601 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
603 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
604 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
605 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
606 * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
609 * dx10 cards usually have 64 varyings */
610 return gl_info
->limits
.glsl_varyings
> 44;
613 static BOOL
match_not_dx10_capable(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
614 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
616 return !match_dx10_capable(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
);
619 /* A GL context is provided by the caller */
620 static BOOL
match_allows_spec_alpha(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
621 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
626 if (!gl_info
->supported
[EXT_SECONDARY_COLOR
])
629 while (gl_info
->gl_ops
.gl
.p_glGetError());
630 GL_EXTCALL(glSecondaryColorPointerEXT
)(4, GL_UNSIGNED_BYTE
, 4, data
);
631 error
= gl_info
->gl_ops
.gl
.p_glGetError();
633 if (error
== GL_NO_ERROR
)
635 TRACE("GL Implementation accepts 4 component specular color pointers\n");
640 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
641 debug_glerror(error
));
646 /* A GL context is provided by the caller */
647 static BOOL
match_broken_nv_clip(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
648 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
653 const char *testcode
=
655 "OPTION NV_vertex_program2;\n"
656 "MOV result.clip[0], 0.0;\n"
657 "MOV result.position, 0.0;\n"
660 if (!gl_info
->supported
[NV_VERTEX_PROGRAM2_OPTION
]) return FALSE
;
662 while (gl_info
->gl_ops
.gl
.p_glGetError());
664 GL_EXTCALL(glGenProgramsARB(1, &prog
));
667 ERR("Failed to create the NVvp clip test program\n");
670 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
671 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
672 strlen(testcode
), testcode
));
673 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &pos
);
676 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
677 TRACE("error: %s\n", debugstr_a((const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
679 while (gl_info
->gl_ops
.gl
.p_glGetError());
681 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
683 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
684 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
685 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
690 /* Context activation is done by the caller. */
691 static BOOL
match_fbo_tex_update(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
692 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
694 char data
[4 * 4 * 4];
698 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
) return FALSE
;
700 memset(data
, 0xcc, sizeof(data
));
702 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
703 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
704 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
705 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
706 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
);
707 checkGLcall("glTexImage2D");
709 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
710 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
711 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
712 checkGLcall("glFramebufferTexture2D");
714 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
715 if (status
!= GL_FRAMEBUFFER_COMPLETE
) ERR("FBO status %#x\n", status
);
716 checkGLcall("glCheckFramebufferStatus");
718 memset(data
, 0x11, sizeof(data
));
719 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
);
720 checkGLcall("glTexSubImage2D");
722 gl_info
->gl_ops
.gl
.p_glClearColor(0.996f
, 0.729f
, 0.745f
, 0.792f
);
723 gl_info
->gl_ops
.gl
.p_glClear(GL_COLOR_BUFFER_BIT
);
724 checkGLcall("glClear");
726 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
727 checkGLcall("glGetTexImage");
729 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 0, 0);
730 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
731 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
732 checkGLcall("glBindTexture");
734 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
735 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
736 checkGLcall("glDeleteTextures");
738 return *(DWORD
*)data
== 0x11111111;
741 /* Context activation is done by the caller. */
742 static BOOL
match_broken_rgba16(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
743 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
745 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
746 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
750 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
751 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
752 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA16
, 4, 4, 0, GL_RGBA
, GL_UNSIGNED_SHORT
, NULL
);
753 checkGLcall("glTexImage2D");
755 gl_info
->gl_ops
.gl
.p_glGetTexLevelParameteriv(GL_TEXTURE_2D
, 0, GL_TEXTURE_RED_SIZE
, &size
);
756 checkGLcall("glGetTexLevelParameteriv");
757 TRACE("Real color depth is %d\n", size
);
759 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
760 checkGLcall("glBindTexture");
761 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
762 checkGLcall("glDeleteTextures");
767 static BOOL
match_fglrx(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
768 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
770 return gl_vendor
== GL_VENDOR_FGLRX
;
773 static BOOL
match_r200(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
774 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
776 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
777 if (device
== CARD_AMD_RADEON_8500
) return TRUE
;
781 static BOOL
match_broken_arb_fog(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
782 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
787 float color
[4] = {0.0f
, 1.0f
, 0.0f
, 0.0f
};
790 static const char *program_code
=
792 "OPTION ARB_fog_linear;\n"
793 "MOV result.color, {1.0, 0.0, 0.0, 0.0};\n"
796 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
798 if (!gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
801 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
802 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
803 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
804 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
805 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
);
806 checkGLcall("glTexImage2D");
808 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
809 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
810 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
811 checkGLcall("glFramebufferTexture2D");
813 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
814 if (status
!= GL_FRAMEBUFFER_COMPLETE
) ERR("FBO status %#x\n", status
);
815 checkGLcall("glCheckFramebufferStatus");
817 gl_info
->gl_ops
.gl
.p_glClearColor(0.0f
, 0.0f
, 1.0f
, 0.0f
);
818 gl_info
->gl_ops
.gl
.p_glClear(GL_COLOR_BUFFER_BIT
);
819 checkGLcall("glClear");
820 gl_info
->gl_ops
.gl
.p_glViewport(0, 0, 4, 1);
821 checkGLcall("glViewport");
823 gl_info
->gl_ops
.gl
.p_glEnable(GL_FOG
);
824 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_START
, 0.5f
);
825 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_END
, 0.5f
);
826 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
827 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_NICEST
);
828 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_COLOR
, color
);
829 checkGLcall("fog setup");
831 GL_EXTCALL(glGenProgramsARB(1, &prog
));
832 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, prog
));
833 GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
834 strlen(program_code
), program_code
));
835 gl_info
->gl_ops
.gl
.p_glEnable(GL_FRAGMENT_PROGRAM_ARB
);
836 checkGLcall("Test fragment program setup");
838 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &err_pos
);
841 const char *error_str
;
842 error_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB
);
843 FIXME("Fog test program error at position %d: %s\n\n", err_pos
, debugstr_a(error_str
));
846 gl_info
->gl_ops
.gl
.p_glBegin(GL_TRIANGLE_STRIP
);
847 gl_info
->gl_ops
.gl
.p_glVertex3f(-1.0f
, -1.0f
, 0.0f
);
848 gl_info
->gl_ops
.gl
.p_glVertex3f( 1.0f
, -1.0f
, 1.0f
);
849 gl_info
->gl_ops
.gl
.p_glVertex3f(-1.0f
, 1.0f
, 0.0f
);
850 gl_info
->gl_ops
.gl
.p_glVertex3f( 1.0f
, 1.0f
, 1.0f
);
851 gl_info
->gl_ops
.gl
.p_glEnd();
852 checkGLcall("ARBfp fog test draw");
854 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
855 checkGLcall("glGetTexImage");
856 data
[0] &= 0x00ffffff;
857 data
[1] &= 0x00ffffff;
858 data
[2] &= 0x00ffffff;
859 data
[3] &= 0x00ffffff;
861 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
862 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
864 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
865 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
866 gl_info
->gl_ops
.gl
.p_glDisable(GL_FOG
);
867 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, 0));
868 gl_info
->gl_ops
.gl
.p_glDisable(GL_FRAGMENT_PROGRAM_ARB
);
869 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
870 checkGLcall("ARBfp fog test teardown");
872 TRACE("Fog test data: %08x %08x %08x %08x\n", data
[0], data
[1], data
[2], data
[3]);
873 return data
[0] != 0x00ff0000 || data
[3] != 0x0000ff00;
876 static void quirk_apple_glsl_constants(struct wined3d_gl_info
*gl_info
)
878 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
879 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
880 * allow 48 different offsets or other helper immediate values. */
881 TRACE("Reserving 12 GLSL constants for compiler private use.\n");
882 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 12);
885 static void quirk_amd_dx9(struct wined3d_gl_info
*gl_info
)
887 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
888 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
889 * If real NP2 textures are used, the driver falls back to software. We could just remove the
890 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconvenient
891 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
892 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
893 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
895 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
896 * has this extension promoted to core. The extension loading code sets this extension supported
897 * due to that, so this code works on fglrx as well. */
898 if(gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
900 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
901 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
902 gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
] = TRUE
;
906 static void quirk_no_np2(struct wined3d_gl_info
*gl_info
)
908 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
909 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
910 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
911 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
912 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
913 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
915 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
916 * triggering the software fallback. There is not much we can do here apart from disabling the
917 * software-emulated extension and re-enable ARB_tex_rect (which was previously disabled
918 * in wined3d_adapter_init_gl_caps).
919 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
920 * post-processing effects in the game "Max Payne 2").
921 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
922 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
923 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
924 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = TRUE
;
927 static void quirk_texcoord_w(struct wined3d_gl_info
*gl_info
)
929 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
930 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
931 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
932 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
933 * according to the spec.
935 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
936 * makes the shader slower and eats instruction slots which should be available to the d3d app.
938 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
939 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
940 * this workaround is activated on cards that do not need it, it won't break things, just affect
941 * performance negatively. */
942 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
943 gl_info
->quirks
|= WINED3D_QUIRK_SET_TEXCOORD_W
;
946 static void quirk_clip_varying(struct wined3d_gl_info
*gl_info
)
948 gl_info
->quirks
|= WINED3D_QUIRK_GLSL_CLIP_VARYING
;
951 static void quirk_allows_specular_alpha(struct wined3d_gl_info
*gl_info
)
953 gl_info
->quirks
|= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
;
956 static void quirk_disable_nvvp_clip(struct wined3d_gl_info
*gl_info
)
958 gl_info
->quirks
|= WINED3D_QUIRK_NV_CLIP_BROKEN
;
961 static void quirk_fbo_tex_update(struct wined3d_gl_info
*gl_info
)
963 gl_info
->quirks
|= WINED3D_QUIRK_FBO_TEX_UPDATE
;
966 static void quirk_broken_rgba16(struct wined3d_gl_info
*gl_info
)
968 gl_info
->quirks
|= WINED3D_QUIRK_BROKEN_RGBA16
;
971 static void quirk_infolog_spam(struct wined3d_gl_info
*gl_info
)
973 gl_info
->quirks
|= WINED3D_QUIRK_INFO_LOG_SPAM
;
976 static void quirk_limited_tex_filtering(struct wined3d_gl_info
*gl_info
)
978 /* Nvidia GeForce 6xxx and 7xxx support accelerated VTF only on a few
979 selected texture formats. They are apparently the only DX9 class GPUs
981 Also, DX9-era GPUs are somewhat limited with float textures
982 filtering and blending. */
983 gl_info
->quirks
|= WINED3D_QUIRK_LIMITED_TEX_FILTERING
;
986 static void quirk_r200_constants(struct wined3d_gl_info
*gl_info
)
988 /* The Mesa r200 driver (and there is no other driver for this GPU Wine would run on)
989 * loads some fog parameters (start, end, exponent, but not the color) into the
992 * Apparently the fog hardware is only able to handle linear fog with a range of 0.0;1.0,
993 * and it is the responsibility of the vertex pipeline to handle non-linear fog and
994 * linear fog with start and end other than 0.0 and 1.0. */
995 TRACE("Reserving 1 ARB constant for compiler private use.\n");
996 gl_info
->reserved_arb_constants
= max(gl_info
->reserved_arb_constants
, 1);
999 static void quirk_broken_arb_fog(struct wined3d_gl_info
*gl_info
)
1001 gl_info
->quirks
|= WINED3D_QUIRK_BROKEN_ARB_FOG
;
1006 BOOL (*match
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
1007 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
);
1008 void (*apply
)(struct wined3d_gl_info
*gl_info
);
1009 const char *description
;
1012 static const struct driver_quirk quirk_table
[] =
1015 match_amd_r300_to_500
,
1017 "AMD normalized texrect quirk"
1021 quirk_apple_glsl_constants
,
1022 "Apple GLSL uniform override"
1027 "Geforce 5 NP2 disable"
1032 "Init texcoord .w for Apple Intel GPU driver"
1035 match_apple_nonr500ati
,
1037 "Init texcoord .w for Apple ATI >= r600 GPU driver"
1042 "Reserved varying for gl_ClipPos"
1045 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
1046 * GL implementations accept it. The Mac GL is the only implementation known to
1049 * If we can pass 4 component specular colors, do it, because (a) we don't have
1050 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
1051 * passes specular alpha to the pixel shader if any is used. Otherwise the
1052 * specular alpha is used to pass the fog coordinate, which we pass to opengl
1053 * via GL_EXT_fog_coord.
1055 match_allows_spec_alpha
,
1056 quirk_allows_specular_alpha
,
1057 "Allow specular alpha quirk"
1060 match_broken_nv_clip
,
1061 quirk_disable_nvvp_clip
,
1062 "Apple NV_vertex_program clip bug quirk"
1065 match_fbo_tex_update
,
1066 quirk_fbo_tex_update
,
1067 "FBO rebind for attachment updates"
1070 match_broken_rgba16
,
1071 quirk_broken_rgba16
,
1072 "True RGBA16 is not available"
1077 "Not printing GLSL infolog"
1080 match_not_dx10_capable
,
1081 quirk_limited_tex_filtering
,
1082 "Texture filtering, blending and VTF support is limited"
1086 quirk_r200_constants
,
1087 "r200 vertex shader constants"
1090 match_broken_arb_fog
,
1091 quirk_broken_arb_fog
,
1092 "ARBfp fogstart == fogend workaround"
1096 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
1097 * reporting a driver version is moot because we are not the Windows driver, and we have different
1098 * bugs, features, etc.
1100 * The driver version has the form "x.y.z.w".
1102 * "x" is the Windows version the driver is meant for:
1109 * "y" is the maximum Direct3D version the driver supports.
1110 * y -> d3d version mapping:
1119 * "z" is the subversion number.
1121 * "w" is the vendor specific driver build number.
1124 struct driver_version_information
1126 enum wined3d_display_driver driver
;
1127 enum wined3d_driver_model driver_model
;
1128 const char *driver_name
; /* name of Windows driver */
1129 WORD version
; /* version word ('y'), contained in low word of DriverVersion.HighPart */
1130 WORD subversion
; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
1131 WORD build
; /* build number ('w'), contained in low word of DriverVersion.LowPart */
1134 /* The driver version table contains driver information for different devices on several OS versions. */
1135 static const struct driver_version_information driver_version_table
[] =
1138 * - Radeon HD2x00 (R600) and up supported by current drivers.
1139 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
1140 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
1141 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
1142 {DRIVER_AMD_RAGE_128PRO
, DRIVER_MODEL_NT5X
, "ati2dvaa.dll", 13, 3279, 0},
1143 {DRIVER_AMD_R100
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6614},
1144 {DRIVER_AMD_R300
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 6764},
1145 {DRIVER_AMD_R600
, DRIVER_MODEL_NT5X
, "ati2dvag.dll", 14, 10, 8681},
1146 {DRIVER_AMD_R300
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
1147 {DRIVER_AMD_R600
, DRIVER_MODEL_NT6X
, "atiumdag.dll", 14, 10, 741 },
1150 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
1151 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
1152 * igxprd32.dll but the GMA800 driver was never updated. */
1153 {DRIVER_INTEL_GMA800
, DRIVER_MODEL_NT5X
, "ialmrnt5.dll", 14, 10, 3889},
1154 {DRIVER_INTEL_GMA900
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4764},
1155 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 4926},
1156 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT5X
, "igxprd32.dll", 14, 10, 5218},
1157 {DRIVER_INTEL_GMA950
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 14, 10, 1504},
1158 {DRIVER_INTEL_GMA3000
, DRIVER_MODEL_NT6X
, "igdumd32.dll", 15, 10, 1666},
1161 * - Geforce6 and newer cards are supported by the current driver (197.x) on XP-Win7
1162 * - GeforceFX support is up to 173.x on <= XP
1163 * - Geforce2MX/3/4 up to 96.x on <= XP
1164 * - TNT/Geforce1/2 up to 71.x on <= XP
1165 * All version numbers used below are from the Linux nvidia drivers. */
1166 {DRIVER_NVIDIA_TNT
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 7186},
1167 {DRIVER_NVIDIA_GEFORCE2MX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 10, 9371},
1168 {DRIVER_NVIDIA_GEFORCEFX
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 14, 11, 7516},
1169 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT5X
, "nv4_disp.dll", 15, 12, 6658},
1170 {DRIVER_NVIDIA_GEFORCE6
, DRIVER_MODEL_NT6X
, "nvd3dum.dll", 15, 12, 6658},
1173 struct gpu_description
1175 WORD vendor
; /* reported PCI card vendor ID */
1176 WORD card
; /* reported PCI card device ID */
1177 const char *description
; /* Description of the card e.g. NVIDIA RIVA TNT */
1178 enum wined3d_display_driver driver
;
1179 unsigned int vidmem
;
1182 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1183 * found on a board containing a specific GPU. */
1184 static const struct gpu_description gpu_description_table
[] =
1187 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT
, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT
, 16 },
1188 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_RIVA_TNT2
, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1189 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE
, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT
, 32 },
1190 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2
, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT
, 32 },
1191 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE2_MX
, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX
,32 },
1192 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE3
, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1193 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_MX
, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX
,64 },
1194 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE4_TI4200
, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX
,64, },
1195 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5200
, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX
, 64 },
1196 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5600
, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX
, 128 },
1197 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCEFX_5800
, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX
, 256 },
1198 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6200
, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6
, 64 },
1199 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6600GT
, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6
, 128 },
1200 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_6800
, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6
, 128 },
1201 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7300
, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6
, 256 },
1202 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7400
, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6
, 256 },
1203 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7600
, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1204 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_7800GT
, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1205 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8300GS
, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1206 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8400GS
, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE6
, 128 },
1207 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600GT
, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1208 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8600MGT
, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1209 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTS
, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE6
, 320 },
1210 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_8800GTX
, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE6
, 768 },
1211 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9200
, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE6
, 256 },
1212 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9300
, "NVIDIA GeForce 9300", DRIVER_NVIDIA_GEFORCE6
, 256 },
1213 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9400M
, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE6
, 256 },
1214 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9400GT
, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1215 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9500GT
, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE6
, 256 },
1216 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9600GT
, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE6
, 384 },
1217 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_9800GT
, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE6
, 512 },
1218 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_210
, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE6
, 512 },
1219 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT220
, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE6
, 512 },
1220 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT240
, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE6
, 512 },
1221 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX260
, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE6
, 1024},
1222 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX275
, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE6
, 896 },
1223 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX280
, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE6
, 1024},
1224 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_315M
, "NVIDIA GeForce 315M", DRIVER_NVIDIA_GEFORCE6
, 512 },
1225 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_320M
, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE6
, 256},
1226 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_410M
, "NVIDIA GeForce 410M", DRIVER_NVIDIA_GEFORCE6
, 512},
1227 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT320M
, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1228 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT325M
, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1229 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT330
, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE6
, 1024},
1230 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS350M
, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1231 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT420
, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE6
, 2048},
1232 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT430
, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE6
, 1024},
1233 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT440
, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE6
, 1024},
1234 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTS450
, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE6
, 1024},
1235 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460
, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE6
, 768 },
1236 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX460M
, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_GEFORCE6
, 1536},
1237 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX465
, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE6
, 1024},
1238 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX470
, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE6
, 1280},
1239 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX480
, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE6
, 1536},
1240 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT520
, "NVIDIA GeForce GT 520", DRIVER_NVIDIA_GEFORCE6
, 1024},
1241 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT540M
, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1242 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX550
, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE6
, 1024},
1243 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT555M
, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1244 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560TI
, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE6
, 1024},
1245 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX560
, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE6
, 1024},
1246 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX570
, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE6
, 1280},
1247 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX580
, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE6
, 1536},
1248 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT610
, "NVIDIA GeForce GT 610", DRIVER_NVIDIA_GEFORCE6
, 1024},
1249 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT630
, "NVIDIA GeForce GT 630", DRIVER_NVIDIA_GEFORCE6
, 1024},
1250 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT630M
, "NVIDIA GeForce GT 630M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1251 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT640M
, "NVIDIA GeForce GT 640M", DRIVER_NVIDIA_GEFORCE6
, 1024},
1252 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GT650M
, "NVIDIA GeForce GT 650M", DRIVER_NVIDIA_GEFORCE6
, 2048},
1253 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX650
, "NVIDIA GeForce GTX 650", DRIVER_NVIDIA_GEFORCE6
, 1024},
1254 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX650TI
, "NVIDIA GeForce GTX 650 Ti", DRIVER_NVIDIA_GEFORCE6
, 1024},
1255 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX660
, "NVIDIA GeForce GTX 660", DRIVER_NVIDIA_GEFORCE6
, 2048},
1256 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX660M
, "NVIDIA GeForce GTX 660M", DRIVER_NVIDIA_GEFORCE6
, 2048},
1257 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX660TI
, "NVIDIA GeForce GTX 660 Ti", DRIVER_NVIDIA_GEFORCE6
, 2048},
1258 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX670
, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_GEFORCE6
, 2048},
1259 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX670MX
, "NVIDIA GeForce GTX 670MX", DRIVER_NVIDIA_GEFORCE6
, 3072},
1260 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX680
, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_GEFORCE6
, 2048},
1261 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX765M
, "NVIDIA GeForce GTX 765M", DRIVER_NVIDIA_GEFORCE6
, 2048},
1262 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX770M
, "NVIDIA GeForce GTX 770M", DRIVER_NVIDIA_GEFORCE6
, 3072},
1263 {HW_VENDOR_NVIDIA
, CARD_NVIDIA_GEFORCE_GTX770
, "NVIDIA GeForce GTX 770", DRIVER_NVIDIA_GEFORCE6
, 2048},
1266 {HW_VENDOR_AMD
, CARD_AMD_RAGE_128PRO
, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO
, 16 },
1267 {HW_VENDOR_AMD
, CARD_AMD_RADEON_7200
, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100
, 32 },
1268 {HW_VENDOR_AMD
, CARD_AMD_RADEON_8500
, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100
, 64 },
1269 {HW_VENDOR_AMD
, CARD_AMD_RADEON_9500
, "ATI Radeon 9500", DRIVER_AMD_R300
, 64 },
1270 {HW_VENDOR_AMD
, CARD_AMD_RADEON_XPRESS_200M
, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300
, 64 },
1271 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X700
, "ATI Radeon X700 SE", DRIVER_AMD_R300
, 128 },
1272 {HW_VENDOR_AMD
, CARD_AMD_RADEON_X1600
, "ATI Radeon X1600 Series", DRIVER_AMD_R300
, 128 },
1273 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2350
, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600
, 256 },
1274 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2600
, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600
, 256 },
1275 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD2900
, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600
, 512 },
1276 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD3200
, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600
, 128 },
1277 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4200M
, "ATI Mobility Radeon HD 4200", DRIVER_AMD_R600
, 256 },
1278 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4350
, "ATI Radeon HD 4350", DRIVER_AMD_R600
, 256 },
1279 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4600
, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600
, 512 },
1280 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4700
, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600
, 512 },
1281 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD4800
, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600
, 512 },
1282 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5400
, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600
, 512 },
1283 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5600
, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600
, 512 },
1284 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5700
, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600
, 512 },
1285 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5800
, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600
, 1024},
1286 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD5900
, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600
, 1024},
1287 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6300
, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600
, 1024},
1288 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6400
, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600
, 1024},
1289 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6410D
, "AMD Radeon HD 6410D", DRIVER_AMD_R600
, 1024},
1290 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6550D
, "AMD Radeon HD 6550D", DRIVER_AMD_R600
, 1024},
1291 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6600
, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600
, 1024},
1292 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6600M
, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600
, 512 },
1293 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6700
, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600
, 1024},
1294 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6800
, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600
, 1024},
1295 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD6900
, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600
, 2048},
1296 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD7700
, "AMD Radeon HD 7700 Series", DRIVER_AMD_R600
, 1024},
1297 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD7800
, "AMD Radeon HD 7800 Series", DRIVER_AMD_R600
, 2048},
1298 {HW_VENDOR_AMD
, CARD_AMD_RADEON_HD7900
, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600
, 2048},
1300 {HW_VENDOR_INTEL
, CARD_INTEL_830M
, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1301 {HW_VENDOR_INTEL
, CARD_INTEL_855GM
, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1302 {HW_VENDOR_INTEL
, CARD_INTEL_845G
, "Intel(R) 845G", DRIVER_INTEL_GMA800
, 32 },
1303 {HW_VENDOR_INTEL
, CARD_INTEL_865G
, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800
, 32 },
1304 {HW_VENDOR_INTEL
, CARD_INTEL_915G
, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1305 {HW_VENDOR_INTEL
, CARD_INTEL_E7221G
, "Intel(R) E7221G", DRIVER_INTEL_GMA900
, 64 },
1306 {HW_VENDOR_INTEL
, CARD_INTEL_915GM
, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900
, 64 },
1307 {HW_VENDOR_INTEL
, CARD_INTEL_945G
, "Intel(R) 945G", DRIVER_INTEL_GMA950
, 64 },
1308 {HW_VENDOR_INTEL
, CARD_INTEL_945GM
, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950
, 64 },
1309 {HW_VENDOR_INTEL
, CARD_INTEL_945GME
, "Intel(R) 945GME", DRIVER_INTEL_GMA950
, 64 },
1310 {HW_VENDOR_INTEL
, CARD_INTEL_Q35
, "Intel(R) Q35", DRIVER_INTEL_GMA950
, 64 },
1311 {HW_VENDOR_INTEL
, CARD_INTEL_G33
, "Intel(R) G33", DRIVER_INTEL_GMA950
, 64 },
1312 {HW_VENDOR_INTEL
, CARD_INTEL_Q33
, "Intel(R) Q33", DRIVER_INTEL_GMA950
, 64 },
1313 {HW_VENDOR_INTEL
, CARD_INTEL_PNVG
, "Intel(R) IGD", DRIVER_INTEL_GMA950
, 64 },
1314 {HW_VENDOR_INTEL
, CARD_INTEL_PNVM
, "Intel(R) IGD", DRIVER_INTEL_GMA950
, 64 },
1315 {HW_VENDOR_INTEL
, CARD_INTEL_965Q
, "Intel(R) 965Q", DRIVER_INTEL_GMA3000
, 128},
1316 {HW_VENDOR_INTEL
, CARD_INTEL_965G
, "Intel(R) 965G", DRIVER_INTEL_GMA3000
, 128},
1317 {HW_VENDOR_INTEL
, CARD_INTEL_946GZ
, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000
, 128},
1318 {HW_VENDOR_INTEL
, CARD_INTEL_965GM
, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000
, 128},
1319 {HW_VENDOR_INTEL
, CARD_INTEL_965GME
, "Intel(R) 965GME", DRIVER_INTEL_GMA3000
, 128},
1320 {HW_VENDOR_INTEL
, CARD_INTEL_GM45
, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000
, 512},
1321 {HW_VENDOR_INTEL
, CARD_INTEL_IGD
, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000
, 512},
1322 {HW_VENDOR_INTEL
, CARD_INTEL_G45
, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000
, 512},
1323 {HW_VENDOR_INTEL
, CARD_INTEL_Q45
, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000
, 512},
1324 {HW_VENDOR_INTEL
, CARD_INTEL_G41
, "Intel(R) G41", DRIVER_INTEL_GMA3000
, 512},
1325 {HW_VENDOR_INTEL
, CARD_INTEL_B43
, "Intel(R) B43", DRIVER_INTEL_GMA3000
, 512},
1326 {HW_VENDOR_INTEL
, CARD_INTEL_ILKD
, "Intel(R) Ironlake Desktop", DRIVER_INTEL_GMA3000
, 1024},
1327 {HW_VENDOR_INTEL
, CARD_INTEL_ILKM
, "Intel(R) Ironlake Mobile", DRIVER_INTEL_GMA3000
, 1024},
1328 {HW_VENDOR_INTEL
, CARD_INTEL_SNBD
, "Intel(R) Sandybridge Desktop", DRIVER_INTEL_GMA3000
, 1024},
1329 {HW_VENDOR_INTEL
, CARD_INTEL_SNBM
, "Intel(R) Sandybridge Mobile", DRIVER_INTEL_GMA3000
, 1024},
1330 {HW_VENDOR_INTEL
, CARD_INTEL_SNBS
, "Intel(R) Sandybridge Server", DRIVER_INTEL_GMA3000
, 1024},
1331 {HW_VENDOR_INTEL
, CARD_INTEL_IVBD
, "Intel(R) Ivybridge Desktop", DRIVER_INTEL_GMA3000
, 1024},
1332 {HW_VENDOR_INTEL
, CARD_INTEL_IVBM
, "Intel(R) Ivybridge Mobile", DRIVER_INTEL_GMA3000
, 1024},
1333 {HW_VENDOR_INTEL
, CARD_INTEL_IVBS
, "Intel(R) Ivybridge Server", DRIVER_INTEL_GMA3000
, 1024},
1334 {HW_VENDOR_INTEL
, CARD_INTEL_HWM
, "Intel(R) Haswell Mobile", DRIVER_INTEL_GMA3000
, 1024},
1337 static const struct driver_version_information
*get_driver_version_info(enum wined3d_display_driver driver
,
1338 enum wined3d_driver_model driver_model
)
1342 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver
, driver_model
);
1343 for (i
= 0; i
< (sizeof(driver_version_table
) / sizeof(driver_version_table
[0])); i
++)
1345 const struct driver_version_information
*entry
= &driver_version_table
[i
];
1347 if (entry
->driver
== driver
&& entry
->driver_model
== driver_model
)
1349 TRACE("Found driver \"%s\", version %u, subversion %u, build %u.\n",
1350 entry
->driver_name
, entry
->version
, entry
->subversion
, entry
->build
);
1357 static void init_driver_info(struct wined3d_driver_info
*driver_info
,
1358 enum wined3d_pci_vendor vendor
, enum wined3d_pci_device device
)
1360 OSVERSIONINFOW os_version
;
1361 WORD driver_os_version
;
1363 enum wined3d_display_driver driver
= DRIVER_UNKNOWN
;
1364 enum wined3d_driver_model driver_model
;
1365 const struct driver_version_information
*version_info
;
1367 if (wined3d_settings
.pci_vendor_id
!= PCI_VENDOR_NONE
)
1369 TRACE("Overriding PCI vendor ID with 0x%04x.\n", wined3d_settings
.pci_vendor_id
);
1370 vendor
= wined3d_settings
.pci_vendor_id
;
1372 driver_info
->vendor
= vendor
;
1374 if (wined3d_settings
.pci_device_id
!= PCI_DEVICE_NONE
)
1376 TRACE("Overriding PCI device ID with 0x%04x.\n", wined3d_settings
.pci_device_id
);
1377 device
= wined3d_settings
.pci_device_id
;
1379 driver_info
->device
= device
;
1381 /* Set a default amount of video memory (64MB). In general this code isn't used unless the user
1382 * overrides the pci ids to a card which is not in our database. */
1383 driver_info
->vidmem
= WINE_DEFAULT_VIDMEM
;
1385 memset(&os_version
, 0, sizeof(os_version
));
1386 os_version
.dwOSVersionInfoSize
= sizeof(os_version
);
1387 if (!GetVersionExW(&os_version
))
1389 ERR("Failed to get OS version, reporting 2000/XP.\n");
1390 driver_os_version
= 6;
1391 driver_model
= DRIVER_MODEL_NT5X
;
1395 TRACE("OS version %u.%u.\n", os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1396 switch (os_version
.dwMajorVersion
)
1399 /* If needed we could distinguish between 9x and NT4, but this code won't make
1400 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1402 driver_os_version
= 4;
1403 driver_model
= DRIVER_MODEL_WIN9X
;
1407 driver_os_version
= 6;
1408 driver_model
= DRIVER_MODEL_NT5X
;
1412 if (os_version
.dwMinorVersion
== 0)
1414 driver_os_version
= 7;
1415 driver_model
= DRIVER_MODEL_NT6X
;
1417 else if (os_version
.dwMinorVersion
== 1)
1419 driver_os_version
= 8;
1420 driver_model
= DRIVER_MODEL_NT6X
;
1424 if (os_version
.dwMinorVersion
> 2)
1426 FIXME("Unhandled OS version %u.%u, reporting Win 8.\n",
1427 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1429 driver_os_version
= 9;
1430 driver_model
= DRIVER_MODEL_NT6X
;
1435 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1436 os_version
.dwMajorVersion
, os_version
.dwMinorVersion
);
1437 driver_os_version
= 6;
1438 driver_model
= DRIVER_MODEL_NT5X
;
1443 /* When we reach this stage we always have a vendor or device id (it can be a default one).
1444 * This means that unless the ids are overridden, we will always find a GPU description. */
1445 for (i
= 0; i
< (sizeof(gpu_description_table
) / sizeof(gpu_description_table
[0])); i
++)
1447 if (vendor
== gpu_description_table
[i
].vendor
&& device
== gpu_description_table
[i
].card
)
1449 TRACE("Found card %04x:%04x in driver DB.\n", vendor
, device
);
1451 driver_info
->description
= gpu_description_table
[i
].description
;
1452 driver_info
->vidmem
= gpu_description_table
[i
].vidmem
* 1024*1024;
1453 driver
= gpu_description_table
[i
].driver
;
1458 if (wined3d_settings
.emulated_textureram
)
1460 TRACE("Overriding amount of video memory with %u bytes.\n", wined3d_settings
.emulated_textureram
);
1461 driver_info
->vidmem
= wined3d_settings
.emulated_textureram
;
1464 /* Try to obtain driver version information for the current Windows version. This fails in
1466 * - the gpu is not available on the currently selected OS version:
1467 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1468 * version information for the current Windows version is returned instead of faked info.
1469 * We do the same and assume the default Windows version to emulate is WinXP.
1471 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1472 * For now return the XP driver info. Perhaps later on we should return VESA.
1474 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1475 * This could be an indication that our database is not up to date, so this should be fixed.
1477 version_info
= get_driver_version_info(driver
, driver_model
);
1480 driver_info
->name
= version_info
->driver_name
;
1481 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1482 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1486 version_info
= get_driver_version_info(driver
, DRIVER_MODEL_NT5X
);
1489 driver_info
->name
= version_info
->driver_name
;
1490 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, version_info
->version
);
1491 driver_info
->version_low
= MAKEDWORD_VERSION(version_info
->subversion
, version_info
->build
);
1495 driver_info
->description
= "Direct3D HAL";
1496 driver_info
->name
= "Display";
1497 driver_info
->version_high
= MAKEDWORD_VERSION(driver_os_version
, 15);
1498 driver_info
->version_low
= MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1500 FIXME("Unable to find a driver/device info for vendor_id=%#x device_id=%#x for driver_model=%d\n",
1501 vendor
, device
, driver_model
);
1505 TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1506 driver_info
->version_high
, driver_info
->version_low
);
1509 /* Context activation is done by the caller. */
1510 static void fixup_extensions(struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
1511 enum wined3d_gl_vendor gl_vendor
, enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
1515 for (i
= 0; i
< (sizeof(quirk_table
) / sizeof(*quirk_table
)); ++i
)
1517 if (!quirk_table
[i
].match(gl_info
, gl_renderer
, gl_vendor
, card_vendor
, device
)) continue;
1518 TRACE("Applying driver quirk \"%s\".\n", quirk_table
[i
].description
);
1519 quirk_table
[i
].apply(gl_info
);
1522 /* Find out if PBOs work as they are supposed to. */
1523 test_pbo_functionality(gl_info
);
1526 static DWORD
wined3d_parse_gl_version(const char *gl_version
)
1528 const char *ptr
= gl_version
;
1533 ERR("Invalid OpenGL major version %d.\n", major
);
1535 while (isdigit(*ptr
)) ++ptr
;
1537 ERR("Invalid OpenGL version string %s.\n", debugstr_a(gl_version
));
1541 TRACE("Found OpenGL version %d.%d.\n", major
, minor
);
1543 return MAKEDWORD_VERSION(major
, minor
);
1546 static enum wined3d_gl_vendor
wined3d_guess_gl_vendor(const struct wined3d_gl_info
*gl_info
,
1547 const char *gl_vendor_string
, const char *gl_renderer
)
1550 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1551 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1552 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1554 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1555 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1556 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1557 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1558 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1559 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1560 * DirectDraw, not OpenGL. */
1561 if (gl_info
->supported
[APPLE_FENCE
]
1562 && gl_info
->supported
[APPLE_CLIENT_STORAGE
]
1563 && gl_info
->supported
[APPLE_YCBCR_422
])
1564 return GL_VENDOR_APPLE
;
1566 if (strstr(gl_vendor_string
, "NVIDIA"))
1567 return GL_VENDOR_NVIDIA
;
1569 if (strstr(gl_vendor_string
, "ATI"))
1570 return GL_VENDOR_FGLRX
;
1572 if (strstr(gl_vendor_string
, "Intel(R)")
1573 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1574 || strstr(gl_renderer
, "Intel")
1575 || strstr(gl_vendor_string
, "Intel Inc."))
1576 return GL_VENDOR_INTEL
;
1578 if (strstr(gl_vendor_string
, "Mesa")
1579 || strstr(gl_vendor_string
, "X.Org")
1580 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1581 || strstr(gl_vendor_string
, "DRI R300 Project")
1582 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1583 || strstr(gl_vendor_string
, "VMware, Inc.")
1584 || strstr(gl_renderer
, "Mesa")
1585 || strstr(gl_renderer
, "Gallium"))
1586 return GL_VENDOR_MESA
;
1588 FIXME("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1589 debugstr_a(gl_vendor_string
));
1591 return GL_VENDOR_UNKNOWN
;
1594 static enum wined3d_pci_vendor
wined3d_guess_card_vendor(const char *gl_vendor_string
, const char *gl_renderer
)
1596 if (strstr(gl_vendor_string
, "NVIDIA")
1597 || strstr(gl_vendor_string
, "Nouveau")
1598 || strstr(gl_vendor_string
, "nouveau"))
1599 return HW_VENDOR_NVIDIA
;
1601 if (strstr(gl_vendor_string
, "ATI")
1602 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1603 || strstr(gl_vendor_string
, "X.Org R300 Project")
1604 || strstr(gl_renderer
, "AMD")
1605 || strstr(gl_renderer
, "R100")
1606 || strstr(gl_renderer
, "R200")
1607 || strstr(gl_renderer
, "R300")
1608 || strstr(gl_renderer
, "R600")
1609 || strstr(gl_renderer
, "R700"))
1610 return HW_VENDOR_AMD
;
1612 if (strstr(gl_vendor_string
, "Intel(R)")
1613 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1614 || strstr(gl_renderer
, "Intel")
1615 || strstr(gl_renderer
, "i915")
1616 || strstr(gl_vendor_string
, "Intel Inc."))
1617 return HW_VENDOR_INTEL
;
1619 if (strstr(gl_vendor_string
, "Mesa")
1620 || strstr(gl_vendor_string
, "Brian Paul")
1621 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1622 || strstr(gl_vendor_string
, "VMware, Inc."))
1623 return HW_VENDOR_SOFTWARE
;
1625 FIXME("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string
));
1627 return HW_VENDOR_NVIDIA
;
1630 static UINT
d3d_level_from_gl_info(const struct wined3d_gl_info
*gl_info
)
1634 if (gl_info
->supported
[ARB_MULTITEXTURE
])
1636 if (gl_info
->supported
[ARB_TEXTURE_COMPRESSION
]
1637 && gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
]
1638 && gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
1640 if (level
== 7 && gl_info
->supported
[ARB_MULTISAMPLE
]
1641 && gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
1643 if (level
== 8 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]
1644 && gl_info
->supported
[ARB_VERTEX_SHADER
])
1646 if (level
== 9 && gl_info
->supported
[EXT_GPU_SHADER4
])
1652 static enum wined3d_pci_device
select_card_nvidia_binary(const struct wined3d_gl_info
*gl_info
,
1653 const char *gl_renderer
)
1655 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
1658 if (d3d_level
>= 10)
1662 const char *renderer
;
1663 enum wined3d_pci_device id
;
1667 {"GTX 770M", CARD_NVIDIA_GEFORCE_GTX770M
}, /* Geforce 700 - midend high mobile */
1668 {"GTX 770", CARD_NVIDIA_GEFORCE_GTX770
}, /* Geforce 700 - highend */
1669 {"GTX 765M", CARD_NVIDIA_GEFORCE_GTX765M
}, /* Geforce 700 - midend high mobile */
1670 {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680
}, /* Geforce 600 - highend */
1671 {"GTX 670MX", CARD_NVIDIA_GEFORCE_GTX670MX
}, /* Geforce 600 - highend */
1672 {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670
}, /* Geforce 600 - midend high */
1673 {"GTX 660 Ti", CARD_NVIDIA_GEFORCE_GTX660TI
}, /* Geforce 600 - midend high */
1674 {"GTX 660M", CARD_NVIDIA_GEFORCE_GTX660M
}, /* Geforce 600 - midend high mobile */
1675 {"GTX 660", CARD_NVIDIA_GEFORCE_GTX660
}, /* Geforce 600 - midend high */
1676 {"GTX 650 Ti", CARD_NVIDIA_GEFORCE_GTX650TI
}, /* Geforce 600 - lowend */
1677 {"GTX 650", CARD_NVIDIA_GEFORCE_GTX650
}, /* Geforce 600 - lowend */
1678 {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M
}, /* Geforce 600 - midend mobile */
1679 {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M
}, /* Geforce 600 - midend mobile */
1680 {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M
}, /* Geforce 600 - midend mobile */
1681 {"GT 630", CARD_NVIDIA_GEFORCE_GT630
}, /* Geforce 600 - lowend */
1682 {"GT 610", CARD_NVIDIA_GEFORCE_GT610
}, /* Geforce 600 - lowend */
1683 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580
}, /* Geforce 500 - highend */
1684 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570
}, /* Geforce 500 - midend high */
1685 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI
}, /* Geforce 500 - midend */
1686 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560
}, /* Geforce 500 - midend */
1687 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M
}, /* Geforce 500 - midend mobile */
1688 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550
}, /* Geforce 500 - midend */
1689 {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M
}, /* Geforce 500 - midend mobile */
1690 {"GT 520", CARD_NVIDIA_GEFORCE_GT520
}, /* Geforce 500 - lowend */
1691 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480
}, /* Geforce 400 - highend */
1692 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470
}, /* Geforce 400 - midend high */
1693 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465
}, /* Geforce 400 - midend */
1694 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M
}, /* Geforce 400 - highend mobile */
1695 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460
}, /* Geforce 400 - midend */
1696 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450
}, /* Geforce 400 - midend low */
1697 {"GT 440", CARD_NVIDIA_GEFORCE_GT440
}, /* Geforce 400 - lowend */
1698 {"GT 430", CARD_NVIDIA_GEFORCE_GT430
}, /* Geforce 400 - lowend */
1699 {"GT 420", CARD_NVIDIA_GEFORCE_GT420
}, /* Geforce 400 - lowend */
1700 {"410M", CARD_NVIDIA_GEFORCE_410M
}, /* Geforce 400 - lowend mobile */
1701 {"GT 330", CARD_NVIDIA_GEFORCE_GT330
}, /* Geforce 300 - highend */
1702 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1703 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1704 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1705 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1706 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M
}, /* Geforce 300 - midend mobile */
1707 {"320M", CARD_NVIDIA_GEFORCE_320M
}, /* Geforce 300 - midend mobile */
1708 {"315M", CARD_NVIDIA_GEFORCE_315M
}, /* Geforce 300 - midend mobile */
1709 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1710 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1711 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1712 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275
}, /* Geforce 200 - midend high */
1713 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260
}, /* Geforce 200 - midend */
1714 {"GT 240", CARD_NVIDIA_GEFORCE_GT240
}, /* Geforce 200 - midend */
1715 {"GT 220", CARD_NVIDIA_GEFORCE_GT220
}, /* Geforce 200 - lowend */
1716 {"Geforce 310", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1717 {"Geforce 305", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1718 {"Geforce 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1719 {"G 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1720 {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1721 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1722 {"9800", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1723 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1724 {"9600", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1725 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1726 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1727 {"9500", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1728 {"9400M", CARD_NVIDIA_GEFORCE_9400M
}, /* Geforce 9 - lowend */
1729 {"9400", CARD_NVIDIA_GEFORCE_9400GT
}, /* Geforce 9 - lowend */
1730 {"9300", CARD_NVIDIA_GEFORCE_9300
}, /* Geforce 9 - lowend low */
1731 {"9200", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1732 {"9100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1733 {"G 100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1734 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX
}, /* Geforce 8 - highend high */
1735 {"8800", CARD_NVIDIA_GEFORCE_8800GTS
}, /* Geforce 8 - highend */
1736 {"8600M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1737 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1738 {"8700", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1739 {"8600", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1740 {"8500", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1741 {"8400", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1742 {"8300", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1743 {"8200", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1744 {"8100", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1747 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1749 if (strstr(gl_renderer
, cards
[i
].renderer
))
1752 return PCI_DEVICE_NONE
;
1755 /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
1756 * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
1758 if (d3d_level
>= 9 && gl_info
->supported
[NV_VERTEX_PROGRAM3
])
1762 const char *renderer
;
1763 enum wined3d_pci_device id
;
1767 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1768 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1769 {"7950", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1770 {"7900", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1771 {"7800", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1772 {"7700", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1773 {"7600", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1774 {"7400", CARD_NVIDIA_GEFORCE_7400
}, /* Geforce 7 - lower medium */
1775 {"7300", CARD_NVIDIA_GEFORCE_7300
}, /* Geforce 7 - lowend */
1776 {"6800", CARD_NVIDIA_GEFORCE_6800
}, /* Geforce 6 - highend */
1777 {"6700", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1778 {"6610", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1779 {"6600", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1782 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1784 if (strstr(gl_renderer
, cards
[i
].renderer
))
1787 return PCI_DEVICE_NONE
;
1792 /* GeforceFX - highend */
1793 if (strstr(gl_renderer
, "5800")
1794 || strstr(gl_renderer
, "5900")
1795 || strstr(gl_renderer
, "5950")
1796 || strstr(gl_renderer
, "Quadro FX"))
1798 return CARD_NVIDIA_GEFORCEFX_5800
;
1801 /* GeforceFX - midend */
1802 if (strstr(gl_renderer
, "5600")
1803 || strstr(gl_renderer
, "5650")
1804 || strstr(gl_renderer
, "5700")
1805 || strstr(gl_renderer
, "5750"))
1807 return CARD_NVIDIA_GEFORCEFX_5600
;
1810 /* GeforceFX - lowend */
1811 return CARD_NVIDIA_GEFORCEFX_5200
; /* GeforceFX 5100/5200/5250/5300/5500 */
1816 if (strstr(gl_renderer
, "GeForce4 Ti") || strstr(gl_renderer
, "Quadro4"))
1818 return CARD_NVIDIA_GEFORCE4_TI4200
; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
1821 return CARD_NVIDIA_GEFORCE3
; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
1826 if (strstr(gl_renderer
, "GeForce4 MX"))
1828 return CARD_NVIDIA_GEFORCE4_MX
; /* MX420/MX440/MX460/MX4000 */
1831 if (strstr(gl_renderer
, "GeForce2 MX") || strstr(gl_renderer
, "Quadro2 MXR"))
1833 return CARD_NVIDIA_GEFORCE2_MX
; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
1836 if (strstr(gl_renderer
, "GeForce2") || strstr(gl_renderer
, "Quadro2"))
1838 return CARD_NVIDIA_GEFORCE2
; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
1841 return CARD_NVIDIA_GEFORCE
; /* Geforce 256/DDR, Quadro */
1844 if (strstr(gl_renderer
, "TNT2"))
1846 return CARD_NVIDIA_RIVA_TNT2
; /* Riva TNT2 standard/M64/Pro/Ultra */
1849 return CARD_NVIDIA_RIVA_TNT
; /* Riva TNT, Vanta */
1852 static enum wined3d_pci_device
select_card_amd_binary(const struct wined3d_gl_info
*gl_info
,
1853 const char *gl_renderer
)
1855 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
1857 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1859 * Beware: renderer string do not match exact card model,
1860 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1861 if (d3d_level
>= 10)
1867 const char *renderer
;
1868 enum wined3d_pci_device id
;
1872 /* Southern Islands */
1873 {"HD 7900", CARD_AMD_RADEON_HD7900
},
1874 {"HD 7800", CARD_AMD_RADEON_HD7800
},
1875 {"HD 7700", CARD_AMD_RADEON_HD7700
},
1876 /* Northern Islands */
1877 {"HD 6970", CARD_AMD_RADEON_HD6900
},
1878 {"HD 6900", CARD_AMD_RADEON_HD6900
},
1879 {"HD 6800", CARD_AMD_RADEON_HD6800
},
1880 {"HD 6770M",CARD_AMD_RADEON_HD6600M
},
1881 {"HD 6750M",CARD_AMD_RADEON_HD6600M
},
1882 {"HD 6700", CARD_AMD_RADEON_HD6700
},
1883 {"HD 6670", CARD_AMD_RADEON_HD6600
},
1884 {"HD 6630M",CARD_AMD_RADEON_HD6600M
},
1885 {"HD 6600M",CARD_AMD_RADEON_HD6600M
},
1886 {"HD 6600", CARD_AMD_RADEON_HD6600
},
1887 {"HD 6570", CARD_AMD_RADEON_HD6600
},
1888 {"HD 6500M",CARD_AMD_RADEON_HD6600M
},
1889 {"HD 6500", CARD_AMD_RADEON_HD6600
},
1890 {"HD 6400", CARD_AMD_RADEON_HD6400
},
1891 {"HD 6300", CARD_AMD_RADEON_HD6300
},
1892 {"HD 6200", CARD_AMD_RADEON_HD6300
},
1894 {"HD 5870", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS PRO */
1895 {"HD 5850", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS XT */
1896 {"HD 5800", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1897 {"HD 5770", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER XT */
1898 {"HD 5750", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER LE */
1899 {"HD 5700", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1900 {"HD 5670", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD XT */
1901 {"HD 5570", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1902 {"HD 5550", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1903 {"HD 5450", CARD_AMD_RADEON_HD5400
}, /* Radeon EG CEDAR PRO */
1904 {"HD 5000", CARD_AMD_RADEON_HD5600
}, /* Defaulting to HD 5600 */
1906 {"HD 4890", CARD_AMD_RADEON_HD4800
}, /* Radeon RV790 */
1907 {"HD 4870", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1908 {"HD 4850", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1909 {"HD 4830", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1910 {"HD 4800", CARD_AMD_RADEON_HD4800
}, /* Radeon RV7xx HD48xx generic renderer string */
1911 {"HD 4770", CARD_AMD_RADEON_HD4700
}, /* Radeon RV740 */
1912 {"HD 4700", CARD_AMD_RADEON_HD4700
}, /* Radeon RV7xx HD47xx generic renderer string */
1913 {"HD 4670", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1914 {"HD 4650", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1915 {"HD 4600", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1916 {"HD 4550", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1917 {"HD 4350", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1918 /* R600/R700 integrated */
1919 {"HD 4200M", CARD_AMD_RADEON_HD4200M
},
1920 {"HD 3300", CARD_AMD_RADEON_HD3200
},
1921 {"HD 3200", CARD_AMD_RADEON_HD3200
},
1922 {"HD 3100", CARD_AMD_RADEON_HD3200
},
1924 {"HD 3870", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1925 {"HD 3850", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1926 {"HD 2900", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1927 {"HD 3830", CARD_AMD_RADEON_HD2600
}, /* China-only midend */
1928 {"HD 3690", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1929 {"HD 3650", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1930 {"HD 2600", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1931 {"HD 3470", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1932 {"HD 3450", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1933 {"HD 3430", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1934 {"HD 3400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1935 {"HD 2400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1936 {"HD 2350", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1939 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
1941 if (strstr(gl_renderer
, cards
[i
].renderer
))
1944 return PCI_DEVICE_NONE
;
1950 if (strstr(gl_renderer
, "X1600")
1951 || strstr(gl_renderer
, "X1650")
1952 || strstr(gl_renderer
, "X1800")
1953 || strstr(gl_renderer
, "X1900")
1954 || strstr(gl_renderer
, "X1950"))
1956 return CARD_AMD_RADEON_X1600
;
1959 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1960 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1961 if (strstr(gl_renderer
, "X700")
1962 || strstr(gl_renderer
, "X800")
1963 || strstr(gl_renderer
, "X850")
1964 || strstr(gl_renderer
, "X1300")
1965 || strstr(gl_renderer
, "X1400")
1966 || strstr(gl_renderer
, "X1450")
1967 || strstr(gl_renderer
, "X1550")
1968 || strstr(gl_renderer
, "X2300")
1969 || strstr(gl_renderer
, "X2500")
1970 || strstr(gl_renderer
, "HD 2300")
1973 return CARD_AMD_RADEON_X700
;
1976 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1977 if (strstr(gl_renderer
, "Radeon Xpress"))
1979 return CARD_AMD_RADEON_XPRESS_200M
;
1982 return PCI_DEVICE_NONE
;
1985 static enum wined3d_pci_device
select_card_intel(const struct wined3d_gl_info
*gl_info
,
1986 const char *gl_renderer
)
1992 const char *renderer
;
1993 enum wined3d_pci_device id
;
1998 {"Haswell Mobile", CARD_INTEL_HWM
},
2000 {"Ivybridge Server", CARD_INTEL_IVBS
},
2001 {"Ivybridge Mobile", CARD_INTEL_IVBM
},
2002 {"Ivybridge Desktop", CARD_INTEL_IVBD
},
2004 {"Sandybridge Server", CARD_INTEL_SNBS
},
2005 {"Sandybridge Mobile", CARD_INTEL_SNBM
},
2006 {"Sandybridge Desktop", CARD_INTEL_SNBD
},
2008 {"Ironlake Mobile", CARD_INTEL_ILKM
},
2009 {"Ironlake Desktop", CARD_INTEL_ILKD
},
2011 {"B43", CARD_INTEL_B43
},
2012 {"G41", CARD_INTEL_G41
},
2013 {"G45", CARD_INTEL_G45
},
2014 {"Q45", CARD_INTEL_Q45
},
2015 {"Integrated Graphics Device", CARD_INTEL_IGD
},
2016 {"GM45", CARD_INTEL_GM45
},
2018 {"965GME", CARD_INTEL_965GME
},
2019 {"965GM", CARD_INTEL_965GM
},
2020 {"X3100", CARD_INTEL_965GM
}, /* MacOS */
2021 {"946GZ", CARD_INTEL_946GZ
},
2022 {"965G", CARD_INTEL_965G
},
2023 {"965Q", CARD_INTEL_965Q
},
2025 {"Pineview M", CARD_INTEL_PNVM
},
2026 {"Pineview G", CARD_INTEL_PNVG
},
2027 {"IGD", CARD_INTEL_PNVG
},
2028 {"Q33", CARD_INTEL_Q33
},
2029 {"G33", CARD_INTEL_G33
},
2030 {"Q35", CARD_INTEL_Q35
},
2031 {"945GME", CARD_INTEL_945GME
},
2032 {"945GM", CARD_INTEL_945GM
},
2033 {"GMA 950", CARD_INTEL_945GM
}, /* MacOS */
2034 {"945G", CARD_INTEL_945G
},
2036 {"915GM", CARD_INTEL_915GM
},
2037 {"E7221G", CARD_INTEL_E7221G
},
2038 {"915G", CARD_INTEL_915G
},
2040 {"865G", CARD_INTEL_865G
},
2041 {"845G", CARD_INTEL_845G
},
2042 {"855GM", CARD_INTEL_855GM
},
2043 {"830M", CARD_INTEL_830M
},
2046 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
2048 if (strstr(gl_renderer
, cards
[i
].renderer
))
2052 return PCI_DEVICE_NONE
;
2055 static enum wined3d_pci_device
select_card_amd_mesa(const struct wined3d_gl_info
*gl_info
,
2056 const char *gl_renderer
)
2060 /* 20101109 - These are never returned by current Gallium radeon
2061 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
2063 * These are returned but not handled: RC410, RV380. */
2066 const char *renderer
;
2067 enum wined3d_pci_device id
;
2071 /* Southern Islands */
2072 {"TAHITI", CARD_AMD_RADEON_HD7900
},
2073 {"PITCAIRN", CARD_AMD_RADEON_HD7800
},
2074 {"CAPE VERDE", CARD_AMD_RADEON_HD7700
},
2075 /* Northern Islands */
2076 {"CAYMAN", CARD_AMD_RADEON_HD6900
},
2077 {"BARTS", CARD_AMD_RADEON_HD6800
},
2078 {"TURKS", CARD_AMD_RADEON_HD6600
},
2079 {"SUMO2", CARD_AMD_RADEON_HD6410D
}, /* SUMO2 first, because we do a strstr(). */
2080 {"SUMO", CARD_AMD_RADEON_HD6550D
},
2081 {"CAICOS", CARD_AMD_RADEON_HD6400
},
2082 {"PALM", CARD_AMD_RADEON_HD6300
},
2084 {"HEMLOCK", CARD_AMD_RADEON_HD5900
},
2085 {"CYPRESS", CARD_AMD_RADEON_HD5800
},
2086 {"JUNIPER", CARD_AMD_RADEON_HD5700
},
2087 {"REDWOOD", CARD_AMD_RADEON_HD5600
},
2088 {"CEDAR", CARD_AMD_RADEON_HD5400
},
2090 {"R700", CARD_AMD_RADEON_HD4800
},
2091 {"RV790", CARD_AMD_RADEON_HD4800
},
2092 {"RV770", CARD_AMD_RADEON_HD4800
},
2093 {"RV740", CARD_AMD_RADEON_HD4700
},
2094 {"RV730", CARD_AMD_RADEON_HD4600
},
2095 {"RV710", CARD_AMD_RADEON_HD4350
},
2096 /* R600/R700 integrated */
2097 {"RS880", CARD_AMD_RADEON_HD4200M
},
2098 {"RS780", CARD_AMD_RADEON_HD3200
},
2100 {"R680", CARD_AMD_RADEON_HD2900
},
2101 {"R600", CARD_AMD_RADEON_HD2900
},
2102 {"RV670", CARD_AMD_RADEON_HD2900
},
2103 {"RV635", CARD_AMD_RADEON_HD2600
},
2104 {"RV630", CARD_AMD_RADEON_HD2600
},
2105 {"RV620", CARD_AMD_RADEON_HD2350
},
2106 {"RV610", CARD_AMD_RADEON_HD2350
},
2108 {"R580", CARD_AMD_RADEON_X1600
},
2109 {"R520", CARD_AMD_RADEON_X1600
},
2110 {"RV570", CARD_AMD_RADEON_X1600
},
2111 {"RV560", CARD_AMD_RADEON_X1600
},
2112 {"RV535", CARD_AMD_RADEON_X1600
},
2113 {"RV530", CARD_AMD_RADEON_X1600
},
2114 {"RV516", CARD_AMD_RADEON_X700
},
2115 {"RV515", CARD_AMD_RADEON_X700
},
2117 {"R481", CARD_AMD_RADEON_X700
},
2118 {"R480", CARD_AMD_RADEON_X700
},
2119 {"R430", CARD_AMD_RADEON_X700
},
2120 {"R423", CARD_AMD_RADEON_X700
},
2121 {"R420", CARD_AMD_RADEON_X700
},
2122 {"R410", CARD_AMD_RADEON_X700
},
2123 {"RV410", CARD_AMD_RADEON_X700
},
2124 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400MHz */
2125 {"RS740", CARD_AMD_RADEON_XPRESS_200M
},
2126 {"RS690", CARD_AMD_RADEON_XPRESS_200M
},
2127 {"RS600", CARD_AMD_RADEON_XPRESS_200M
},
2128 {"RS485", CARD_AMD_RADEON_XPRESS_200M
},
2129 {"RS482", CARD_AMD_RADEON_XPRESS_200M
},
2130 {"RS480", CARD_AMD_RADEON_XPRESS_200M
},
2131 {"RS400", CARD_AMD_RADEON_XPRESS_200M
},
2133 {"R360", CARD_AMD_RADEON_9500
},
2134 {"R350", CARD_AMD_RADEON_9500
},
2135 {"R300", CARD_AMD_RADEON_9500
},
2136 {"RV370", CARD_AMD_RADEON_9500
},
2137 {"RV360", CARD_AMD_RADEON_9500
},
2138 {"RV351", CARD_AMD_RADEON_9500
},
2139 {"RV350", CARD_AMD_RADEON_9500
},
2142 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
2144 if (strstr(gl_renderer
, cards
[i
].renderer
))
2148 return PCI_DEVICE_NONE
;
2151 static enum wined3d_pci_device
select_card_nvidia_mesa(const struct wined3d_gl_info
*gl_info
,
2152 const char *gl_renderer
)
2158 const char *renderer
;
2159 enum wined3d_pci_device id
;
2164 {"NVE6", CARD_NVIDIA_GEFORCE_GTX770M
},
2165 {"NVE4", CARD_NVIDIA_GEFORCE_GTX680
},
2167 {"NVD9", CARD_NVIDIA_GEFORCE_GT520
},
2168 {"NVCF", CARD_NVIDIA_GEFORCE_GTX550
},
2169 {"NVCE", CARD_NVIDIA_GEFORCE_GTX560
},
2170 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570
},
2171 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460
},
2172 {"NVC3", CARD_NVIDIA_GEFORCE_GT440
},
2173 {"NVC1", CARD_NVIDIA_GEFORCE_GT420
},
2174 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480
},
2176 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M
},
2177 {"NVAC", CARD_NVIDIA_GEFORCE_8200
},
2178 {"NVAA", CARD_NVIDIA_GEFORCE_8200
},
2179 {"NVA8", CARD_NVIDIA_GEFORCE_210
},
2180 {"NVA5", CARD_NVIDIA_GEFORCE_GT220
},
2181 {"NVA3", CARD_NVIDIA_GEFORCE_GT240
},
2182 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280
},
2183 {"NV98", CARD_NVIDIA_GEFORCE_9200
},
2184 {"NV96", CARD_NVIDIA_GEFORCE_9400GT
},
2185 {"NV94", CARD_NVIDIA_GEFORCE_9600GT
},
2186 {"NV92", CARD_NVIDIA_GEFORCE_9800GT
},
2187 {"NV86", CARD_NVIDIA_GEFORCE_8500GT
},
2188 {"NV84", CARD_NVIDIA_GEFORCE_8600GT
},
2189 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX
},
2191 {"NV68", CARD_NVIDIA_GEFORCE_6200
}, /* 7050 */
2192 {"NV67", CARD_NVIDIA_GEFORCE_6200
}, /* 7000M */
2193 {"NV63", CARD_NVIDIA_GEFORCE_6200
}, /* 7100 */
2194 {"NV4E", CARD_NVIDIA_GEFORCE_6200
}, /* 6100 Go / 6150 Go */
2195 {"NV4C", CARD_NVIDIA_GEFORCE_6200
}, /* 6150SE */
2196 {"NV4B", CARD_NVIDIA_GEFORCE_7600
},
2197 {"NV4A", CARD_NVIDIA_GEFORCE_6200
},
2198 {"NV49", CARD_NVIDIA_GEFORCE_7800GT
}, /* 7900 */
2199 {"NV47", CARD_NVIDIA_GEFORCE_7800GT
},
2200 {"NV46", CARD_NVIDIA_GEFORCE_7400
},
2201 {"NV45", CARD_NVIDIA_GEFORCE_6800
},
2202 {"NV44", CARD_NVIDIA_GEFORCE_6200
},
2203 {"NV43", CARD_NVIDIA_GEFORCE_6600GT
},
2204 {"NV42", CARD_NVIDIA_GEFORCE_6800
},
2205 {"NV41", CARD_NVIDIA_GEFORCE_6800
},
2206 {"NV40", CARD_NVIDIA_GEFORCE_6800
},
2208 {"NV38", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5950 Ultra */
2209 {"NV36", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5700/5750 */
2210 {"NV35", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5900 */
2211 {"NV34", CARD_NVIDIA_GEFORCEFX_5200
},
2212 {"NV31", CARD_NVIDIA_GEFORCEFX_5600
},
2213 {"NV30", CARD_NVIDIA_GEFORCEFX_5800
},
2215 {"nv28", CARD_NVIDIA_GEFORCE4_TI4200
},
2216 {"nv25", CARD_NVIDIA_GEFORCE4_TI4200
},
2217 {"nv20", CARD_NVIDIA_GEFORCE3
},
2219 {"nv1F", CARD_NVIDIA_GEFORCE4_MX
}, /* GF4 MX IGP */
2220 {"nv1A", CARD_NVIDIA_GEFORCE2
}, /* GF2 IGP */
2221 {"nv18", CARD_NVIDIA_GEFORCE4_MX
},
2222 {"nv17", CARD_NVIDIA_GEFORCE4_MX
},
2223 {"nv16", CARD_NVIDIA_GEFORCE2
},
2224 {"nv15", CARD_NVIDIA_GEFORCE2
},
2225 {"nv11", CARD_NVIDIA_GEFORCE2_MX
},
2226 {"nv10", CARD_NVIDIA_GEFORCE
},
2228 {"nv05", CARD_NVIDIA_RIVA_TNT2
},
2229 {"nv04", CARD_NVIDIA_RIVA_TNT
},
2230 {"nv03", CARD_NVIDIA_RIVA_128
},
2233 for (i
= 0; i
< sizeof(cards
) / sizeof(*cards
); ++i
)
2235 if (strstr(gl_renderer
, cards
[i
].renderer
))
2238 return PCI_DEVICE_NONE
;
2241 static const struct gl_vendor_selection
2243 enum wined3d_gl_vendor gl_vendor
;
2244 const char *description
; /* Description of the card selector i.e. Apple OS/X Intel */
2245 enum wined3d_pci_device (*select_card
)(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
);
2247 nvidia_gl_vendor_table
[] =
2249 {GL_VENDOR_NVIDIA
, "Nvidia binary driver", select_card_nvidia_binary
},
2250 {GL_VENDOR_APPLE
, "Apple OSX NVidia binary driver", select_card_nvidia_binary
},
2251 {GL_VENDOR_MESA
, "Mesa Nouveau driver", select_card_nvidia_mesa
},
2253 amd_gl_vendor_table
[] =
2255 {GL_VENDOR_APPLE
, "Apple OSX AMD/ATI binary driver", select_card_amd_binary
},
2256 {GL_VENDOR_FGLRX
, "AMD/ATI binary driver", select_card_amd_binary
},
2257 {GL_VENDOR_MESA
, "Mesa AMD/ATI driver", select_card_amd_mesa
},
2259 intel_gl_vendor_table
[] =
2261 {GL_VENDOR_APPLE
, "Apple OSX Intel binary driver", select_card_intel
},
2262 {GL_VENDOR_INTEL
, "Mesa Intel driver", select_card_intel
},
2263 {GL_VENDOR_MESA
, "Mesa Intel driver", select_card_intel
},
2266 static enum wined3d_pci_device
select_card_fallback_nvidia(const struct wined3d_gl_info
*gl_info
)
2268 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
2269 if (d3d_level
>= 10)
2270 return CARD_NVIDIA_GEFORCE_8800GTX
;
2271 if (d3d_level
>= 9 && gl_info
->supported
[NV_VERTEX_PROGRAM3
])
2272 return CARD_NVIDIA_GEFORCE_6800
;
2274 return CARD_NVIDIA_GEFORCEFX_5800
;
2276 return CARD_NVIDIA_GEFORCE3
;
2278 return CARD_NVIDIA_GEFORCE
;
2280 return CARD_NVIDIA_RIVA_TNT
;
2281 return CARD_NVIDIA_RIVA_128
;
2284 static enum wined3d_pci_device
select_card_fallback_amd(const struct wined3d_gl_info
*gl_info
)
2286 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
2287 if (d3d_level
>= 10)
2288 return CARD_AMD_RADEON_HD2900
;
2290 return CARD_AMD_RADEON_9500
;
2292 return CARD_AMD_RADEON_8500
;
2294 return CARD_AMD_RADEON_7200
;
2295 return CARD_AMD_RAGE_128PRO
;
2298 static enum wined3d_pci_device
select_card_fallback_intel(const struct wined3d_gl_info
*gl_info
)
2300 UINT d3d_level
= d3d_level_from_gl_info(gl_info
);
2301 if (d3d_level
>= 10)
2302 return CARD_INTEL_G45
;
2303 return CARD_INTEL_915G
;
2306 static enum wined3d_pci_device
select_card_handler(const struct gl_vendor_selection
*table
,
2307 unsigned int table_size
, enum wined3d_gl_vendor gl_vendor
,
2308 const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
)
2312 for (i
= 0; i
< table_size
; ++i
)
2314 if (table
[i
].gl_vendor
!= gl_vendor
)
2317 TRACE("Applying card selector \"%s\".\n", table
[i
].description
);
2318 return table
[i
].select_card(gl_info
, gl_renderer
);
2320 FIXME("Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n",
2321 gl_vendor
, debugstr_a(gl_renderer
));
2323 return PCI_DEVICE_NONE
;
2328 enum wined3d_pci_vendor card_vendor
;
2329 const char *description
; /* Description of the card selector i.e. Apple OS/X Intel */
2330 const struct gl_vendor_selection
*gl_vendor_selection
;
2331 unsigned int gl_vendor_count
;
2332 enum wined3d_pci_device (*select_card_fallback
)(const struct wined3d_gl_info
*gl_info
);
2334 card_vendor_table
[] =
2336 {HW_VENDOR_NVIDIA
, "Nvidia", nvidia_gl_vendor_table
,
2337 sizeof(nvidia_gl_vendor_table
) / sizeof(nvidia_gl_vendor_table
[0]),
2338 select_card_fallback_nvidia
},
2339 {HW_VENDOR_AMD
, "AMD", amd_gl_vendor_table
,
2340 sizeof(amd_gl_vendor_table
) / sizeof(amd_gl_vendor_table
[0]),
2341 select_card_fallback_amd
},
2342 {HW_VENDOR_INTEL
, "Intel", intel_gl_vendor_table
,
2343 sizeof(intel_gl_vendor_table
) / sizeof(intel_gl_vendor_table
[0]),
2344 select_card_fallback_intel
},
2348 static enum wined3d_pci_device
wined3d_guess_card(const struct wined3d_gl_info
*gl_info
, const char *gl_renderer
,
2349 enum wined3d_gl_vendor
*gl_vendor
, enum wined3d_pci_vendor
*card_vendor
)
2351 /* A Direct3D device object contains the PCI id (vendor + device) of the
2352 * videocard which is used for rendering. Various applications use this
2353 * information to get a rough estimation of the features of the card and
2354 * some might use it for enabling 3d effects only on certain types of
2355 * videocards. In some cases games might even use it to work around bugs
2356 * which happen on certain videocards/driver combinations. The problem is
2357 * that OpenGL only exposes a rendering string containing the name of the
2358 * videocard and not the PCI id.
2360 * Various games depend on the PCI id, so somehow we need to provide one.
2361 * A simple option is to parse the renderer string and translate this to
2362 * the right PCI id. This is a lot of work because there are more than 200
2363 * GPUs just for Nvidia. Various cards share the same renderer string, so
2364 * the amount of code might be 'small' but there are quite a number of
2365 * exceptions which would make this a pain to maintain. Another way would
2366 * be to query the PCI id from the operating system (assuming this is the
2367 * videocard which is used for rendering which is not always the case).
2368 * This would work but it is not very portable. Second it would not work
2369 * well in, let's say, a remote X situation in which the amount of 3d
2370 * features which can be used is limited.
2372 * As said most games only use the PCI id to get an indication of the
2373 * capabilities of the card. It doesn't really matter if the given id is
2374 * the correct one if we return the id of a card with similar 3d features.
2376 * The code below checks the OpenGL capabilities of a videocard and matches
2377 * that to a certain level of Direct3D functionality. Once a card passes
2378 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
2379 * least a GeforceFX. To give a better estimate we do a basic check on the
2380 * renderer string but if that won't pass we return a default card. This
2381 * way is better than maintaining a full card database as even without a
2382 * full database we can return a card with similar features. Second the
2383 * size of the database can be made quite small because when you know what
2384 * type of 3d functionality a card has, you know to which GPU family the
2385 * GPU must belong. Because of this you only have to check a small part of
2386 * the renderer string to distinguish between different models from that
2389 * The code also selects a default amount of video memory which we will
2390 * use for an estimation of the amount of free texture memory. In case of
2391 * real D3D the amount of texture memory includes video memory and system
2392 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2393 * HyperMemory). We don't know how much system memory can be addressed by
2394 * the system but we can make a reasonable estimation about the amount of
2395 * video memory. If the value is slightly wrong it doesn't matter as we
2396 * didn't include AGP-like memory which makes the amount of addressable
2397 * memory higher and second OpenGL isn't that critical it moves to system
2398 * memory behind our backs if really needed. Note that the amount of video
2399 * memory can be overruled using a registry setting. */
2402 enum wined3d_pci_device device
;
2404 for (i
= 0; i
< (sizeof(card_vendor_table
) / sizeof(*card_vendor_table
)); ++i
)
2406 if (card_vendor_table
[i
].card_vendor
!= *card_vendor
)
2409 TRACE("Applying card selector \"%s\".\n", card_vendor_table
[i
].description
);
2410 device
= select_card_handler(card_vendor_table
[i
].gl_vendor_selection
,
2411 card_vendor_table
[i
].gl_vendor_count
, *gl_vendor
, gl_info
, gl_renderer
);
2412 if (device
!= PCI_DEVICE_NONE
)
2415 TRACE("Unrecognized renderer %s, falling back to default.\n", debugstr_a(gl_renderer
));
2416 return card_vendor_table
[i
].select_card_fallback(gl_info
);
2419 FIXME("No card selector available for card vendor %04x (using GL_RENDERER %s).\n",
2420 *card_vendor
, debugstr_a(gl_renderer
));
2422 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. */
2423 *card_vendor
= HW_VENDOR_NVIDIA
;
2424 return select_card_fallback_nvidia(gl_info
);
2427 static const struct wined3d_vertex_pipe_ops
*select_vertex_implementation(const struct wined3d_gl_info
*gl_info
,
2428 const struct wined3d_shader_backend_ops
*shader_backend_ops
)
2430 if (shader_backend_ops
== &glsl_shader_backend
)
2431 return &glsl_vertex_pipe
;
2432 return &ffp_vertex_pipe
;
2435 static const struct fragment_pipeline
*select_fragment_implementation(const struct wined3d_gl_info
*gl_info
,
2436 const struct wined3d_shader_backend_ops
*shader_backend_ops
)
2438 if (shader_backend_ops
== &glsl_shader_backend
)
2439 return &glsl_fragment_pipe
;
2440 if (shader_backend_ops
== &arb_program_shader_backend
&& gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2441 return &arbfp_fragment_pipeline
;
2442 if (gl_info
->supported
[ATI_FRAGMENT_SHADER
])
2443 return &atifs_fragment_pipeline
;
2444 if (gl_info
->supported
[NV_REGISTER_COMBINERS
] && gl_info
->supported
[NV_TEXTURE_SHADER2
])
2445 return &nvts_fragment_pipeline
;
2446 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2447 return &nvrc_fragment_pipeline
;
2448 return &ffp_fragment_pipeline
;
2451 static const struct wined3d_shader_backend_ops
*select_shader_backend(const struct wined3d_gl_info
*gl_info
)
2453 BOOL glsl
= wined3d_settings
.glslRequested
&& gl_info
->glsl_version
>= MAKEDWORD_VERSION(1, 20);
2455 if (glsl
&& gl_info
->supported
[ARB_FRAGMENT_SHADER
])
2456 return &glsl_shader_backend
;
2457 if (glsl
&& gl_info
->supported
[ARB_VERTEX_SHADER
])
2459 /* Geforce4 cards support GLSL but for vertex shaders only. Further
2460 * its reported GLSL caps are wrong. This combined with the fact that
2461 * GLSL won't offer more features or performance, use ARB shaders only
2463 if (gl_info
->supported
[NV_VERTEX_PROGRAM
] && !gl_info
->supported
[NV_VERTEX_PROGRAM2
])
2464 return &arb_program_shader_backend
;
2465 return &glsl_shader_backend
;
2467 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
] || gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2468 return &arb_program_shader_backend
;
2469 return &none_shader_backend
;
2472 static const struct blit_shader
*select_blit_implementation(const struct wined3d_gl_info
*gl_info
,
2473 const struct wined3d_shader_backend_ops
*shader_backend_ops
)
2475 if ((shader_backend_ops
== &glsl_shader_backend
2476 || shader_backend_ops
== &arb_program_shader_backend
)
2477 && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2482 static void parse_extension_string(struct wined3d_gl_info
*gl_info
, const char *extensions
,
2483 const struct wined3d_extension_map
*map
, UINT entry_count
)
2491 while (isspace(*extensions
))
2494 while (!isspace(*extensions
) && *extensions
)
2497 len
= extensions
- start
;
2501 TRACE("- %s.\n", debugstr_an(start
, len
));
2503 for (i
= 0; i
< entry_count
; ++i
)
2505 if (len
== strlen(map
[i
].extension_string
)
2506 && !memcmp(start
, map
[i
].extension_string
, len
))
2508 TRACE(" FOUND: %s support.\n", map
[i
].extension_string
);
2509 gl_info
->supported
[map
[i
].extension
] = TRUE
;
2516 static void load_gl_funcs(struct wined3d_gl_info
*gl_info
)
2518 #define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
2522 #ifndef USE_WIN32_OPENGL
2523 /* hack: use the functions directly from the TEB table to bypass the thunks */
2524 /* note that we still need the above wglGetProcAddress calls to initialize the table */
2525 gl_info
->gl_ops
.ext
= ((struct opengl_funcs
*)NtCurrentTeb()->glTable
)->ext
;
2529 static void wined3d_adapter_init_limits(struct wined3d_gl_info
*gl_info
)
2531 GLfloat gl_floatv
[2];
2534 gl_info
->limits
.blends
= 1;
2535 gl_info
->limits
.buffers
= 1;
2536 gl_info
->limits
.textures
= 1;
2537 gl_info
->limits
.texture_coords
= 1;
2538 gl_info
->limits
.fragment_samplers
= 1;
2539 gl_info
->limits
.vertex_samplers
= 0;
2540 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
+ gl_info
->limits
.vertex_samplers
;
2541 gl_info
->limits
.vertex_attribs
= 16;
2542 gl_info
->limits
.glsl_vs_float_constants
= 0;
2543 gl_info
->limits
.glsl_ps_float_constants
= 0;
2544 gl_info
->limits
.arb_vs_float_constants
= 0;
2545 gl_info
->limits
.arb_vs_native_constants
= 0;
2546 gl_info
->limits
.arb_vs_instructions
= 0;
2547 gl_info
->limits
.arb_vs_temps
= 0;
2548 gl_info
->limits
.arb_ps_float_constants
= 0;
2549 gl_info
->limits
.arb_ps_local_constants
= 0;
2550 gl_info
->limits
.arb_ps_instructions
= 0;
2551 gl_info
->limits
.arb_ps_temps
= 0;
2553 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
2554 gl_info
->limits
.clipplanes
= min(WINED3DMAXUSERCLIPPLANES
, gl_max
);
2555 TRACE("Clip plane support - max planes %d.\n", gl_max
);
2557 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
2558 gl_info
->limits
.lights
= gl_max
;
2559 TRACE("Light support - max lights %d.\n", gl_max
);
2561 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &gl_max
);
2562 gl_info
->limits
.texture_size
= gl_max
;
2563 TRACE("Maximum texture size support - max texture size %d.\n", gl_max
);
2565 gl_info
->gl_ops
.gl
.p_glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE
, gl_floatv
);
2566 gl_info
->limits
.pointsize_min
= gl_floatv
[0];
2567 gl_info
->limits
.pointsize_max
= gl_floatv
[1];
2568 TRACE("Maximum point size support - max point size %f.\n", gl_floatv
[1]);
2570 if (gl_info
->supported
[ARB_MAP_BUFFER_ALIGNMENT
])
2572 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT
, &gl_max
);
2573 TRACE("Minimum buffer map alignment: %d.\n", gl_max
);
2577 WARN_(d3d_perf
)("Driver doesn't guarantee a minimum buffer map alignment.\n");
2579 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2581 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV
, &gl_max
);
2582 gl_info
->limits
.general_combiners
= gl_max
;
2583 TRACE("Max general combiners: %d.\n", gl_max
);
2585 if (gl_info
->supported
[ARB_DRAW_BUFFERS
] && wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
2587 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &gl_max
);
2588 gl_info
->limits
.buffers
= gl_max
;
2589 TRACE("Max draw buffers: %u.\n", gl_max
);
2591 if (gl_info
->supported
[ARB_MULTITEXTURE
])
2593 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
2594 gl_info
->limits
.textures
= min(MAX_TEXTURES
, gl_max
);
2595 TRACE("Max textures: %d.\n", gl_info
->limits
.textures
);
2597 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2600 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB
, &gl_max
);
2601 gl_info
->limits
.texture_coords
= min(MAX_TEXTURES
, gl_max
);
2602 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2603 gl_info
->limits
.fragment_samplers
= min(MAX_FRAGMENT_SAMPLERS
, tmp
);
2607 gl_info
->limits
.texture_coords
= max(gl_info
->limits
.texture_coords
, gl_max
);
2608 gl_info
->limits
.fragment_samplers
= max(gl_info
->limits
.fragment_samplers
, gl_max
);
2610 TRACE("Max texture coords: %d.\n", gl_info
->limits
.texture_coords
);
2611 TRACE("Max fragment samplers: %d.\n", gl_info
->limits
.fragment_samplers
);
2613 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2616 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2617 gl_info
->limits
.vertex_samplers
= tmp
;
2618 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
, &tmp
);
2619 gl_info
->limits
.combined_samplers
= tmp
;
2620 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB
, &tmp
);
2621 gl_info
->limits
.vertex_attribs
= tmp
;
2623 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
2624 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
2625 * an issue because then the sampler setup only depends on the two shaders. If a pixel
2626 * shader is used with fixed function vertex processing we're fine too because fixed function
2627 * vertex processing doesn't use any samplers. If fixed function fragment processing is
2628 * used we have to make sure that all vertex sampler setups are valid together with all
2629 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
2630 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
2631 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
2632 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
2633 * a fixed function pipeline anymore.
2635 * So this is just a check to check that our assumption holds true. If not, write a warning
2636 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
2637 if (gl_info
->limits
.vertex_samplers
&& gl_info
->limits
.combined_samplers
< 12
2638 && MAX_TEXTURES
+ gl_info
->limits
.vertex_samplers
> gl_info
->limits
.combined_samplers
)
2640 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
2641 gl_info
->limits
.vertex_samplers
, gl_info
->limits
.combined_samplers
);
2642 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
2643 if (gl_info
->limits
.combined_samplers
> MAX_TEXTURES
)
2644 gl_info
->limits
.vertex_samplers
= gl_info
->limits
.combined_samplers
- MAX_TEXTURES
;
2646 gl_info
->limits
.vertex_samplers
= 0;
2651 gl_info
->limits
.combined_samplers
= gl_info
->limits
.fragment_samplers
;
2653 TRACE("Max vertex samplers: %u.\n", gl_info
->limits
.vertex_samplers
);
2654 TRACE("Max combined samplers: %u.\n", gl_info
->limits
.combined_samplers
);
2656 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
2658 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB
, &gl_max
);
2659 gl_info
->limits
.blends
= gl_max
;
2660 TRACE("Max blends: %u.\n", gl_info
->limits
.blends
);
2662 if (gl_info
->supported
[EXT_TEXTURE3D
])
2664 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT
, &gl_max
);
2665 gl_info
->limits
.texture3d_size
= gl_max
;
2666 TRACE("Max texture3D size: %d.\n", gl_info
->limits
.texture3d_size
);
2668 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
2670 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, &gl_max
);
2671 gl_info
->limits
.anisotropy
= gl_max
;
2672 TRACE("Max anisotropy: %d.\n", gl_info
->limits
.anisotropy
);
2674 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2676 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2677 gl_info
->limits
.arb_ps_float_constants
= gl_max
;
2678 TRACE("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_ps_float_constants
);
2679 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2680 gl_info
->limits
.arb_ps_native_constants
= gl_max
;
2681 TRACE("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
2682 gl_info
->limits
.arb_ps_native_constants
);
2683 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2684 gl_info
->limits
.arb_ps_temps
= gl_max
;
2685 TRACE("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_ps_temps
);
2686 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2687 gl_info
->limits
.arb_ps_instructions
= gl_max
;
2688 TRACE("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2689 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB
, &gl_max
));
2690 gl_info
->limits
.arb_ps_local_constants
= gl_max
;
2691 TRACE("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info
->limits
.arb_ps_instructions
);
2693 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
])
2695 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
2696 gl_info
->limits
.arb_vs_float_constants
= gl_max
;
2697 TRACE("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_vs_float_constants
);
2698 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
2699 gl_info
->limits
.arb_vs_native_constants
= gl_max
;
2700 TRACE("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
2701 gl_info
->limits
.arb_vs_native_constants
);
2702 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
2703 gl_info
->limits
.arb_vs_temps
= gl_max
;
2704 TRACE("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_vs_temps
);
2705 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
2706 gl_info
->limits
.arb_vs_instructions
= gl_max
;
2707 TRACE("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_vs_instructions
);
2709 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2711 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2712 gl_info
->limits
.glsl_vs_float_constants
= gl_max
/ 4;
2713 TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info
->limits
.glsl_vs_float_constants
);
2715 if (gl_info
->supported
[ARB_FRAGMENT_SHADER
])
2717 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
, &gl_max
);
2718 gl_info
->limits
.glsl_ps_float_constants
= gl_max
/ 4;
2719 TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info
->limits
.glsl_ps_float_constants
);
2720 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB
, &gl_max
);
2721 gl_info
->limits
.glsl_varyings
= gl_max
;
2722 TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max
, gl_max
/ 4);
2725 if (gl_info
->supported
[NV_LIGHT_MAX_EXPONENT
])
2726 gl_info
->gl_ops
.gl
.p_glGetFloatv(GL_MAX_SHININESS_NV
, &gl_info
->limits
.shininess
);
2728 gl_info
->limits
.shininess
= 128.0f
;
2730 if ((gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
] || gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
2731 && wined3d_settings
.allow_multisampling
)
2733 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_SAMPLES
, &gl_max
);
2734 gl_info
->limits
.samples
= gl_max
;
2738 /* Context activation is done by the caller. */
2739 static BOOL
wined3d_adapter_init_gl_caps(struct wined3d_adapter
*adapter
)
2741 struct wined3d_driver_info
*driver_info
= &adapter
->driver_info
;
2742 const char *gl_vendor_str
, *gl_renderer_str
, *gl_version_str
;
2743 struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
2744 struct wined3d_vertex_caps vertex_caps
;
2745 enum wined3d_pci_vendor card_vendor
;
2746 struct fragment_caps fragment_caps
;
2747 struct shader_caps shader_caps
;
2748 const char *WGL_Extensions
= NULL
;
2749 const char *GL_Extensions
= NULL
;
2750 enum wined3d_gl_vendor gl_vendor
;
2751 enum wined3d_pci_device device
;
2756 TRACE("adapter %p.\n", adapter
);
2758 gl_renderer_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_RENDERER
);
2759 TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str
));
2760 if (!gl_renderer_str
)
2762 ERR("Received a NULL GL_RENDERER.\n");
2766 gl_vendor_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_VENDOR
);
2767 TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str
));
2770 ERR("Received a NULL GL_VENDOR.\n");
2774 /* Parse the GL_VERSION field into major and minor information */
2775 gl_version_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_VERSION
);
2776 TRACE("GL_VERSION: %s.\n", debugstr_a(gl_version_str
));
2777 if (!gl_version_str
)
2779 ERR("Received a NULL GL_VERSION.\n");
2782 gl_version
= wined3d_parse_gl_version(gl_version_str
);
2784 /* Parse the gl supported features, in theory enabling parts of our code appropriately. */
2785 GL_Extensions
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_EXTENSIONS
);
2788 ERR("Received a NULL GL_EXTENSIONS.\n");
2792 memset(gl_info
->supported
, 0, sizeof(gl_info
->supported
));
2793 gl_info
->supported
[WINED3D_GL_EXT_NONE
] = TRUE
;
2795 TRACE("GL extensions reported:\n");
2796 parse_extension_string(gl_info
, GL_Extensions
, gl_extension_map
,
2797 sizeof(gl_extension_map
) / sizeof(*gl_extension_map
));
2799 /* Now work out what GL support this card really has. */
2800 load_gl_funcs( gl_info
);
2802 hdc
= wglGetCurrentDC();
2803 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
2804 if (GL_EXTCALL(wglGetExtensionsStringARB
))
2805 WGL_Extensions
= (const char *)GL_EXTCALL(wglGetExtensionsStringARB(hdc
));
2806 if (!WGL_Extensions
)
2807 WARN("WGL extensions not supported.\n");
2809 parse_extension_string(gl_info
, WGL_Extensions
, wgl_extension_map
,
2810 sizeof(wgl_extension_map
) / sizeof(*wgl_extension_map
));
2812 if (!gl_info
->supported
[EXT_TEXTURE3D
] && gl_version
>= MAKEDWORD_VERSION(1, 2))
2814 TRACE("GL CORE: GL_EXT_texture3D support.\n");
2815 gl_info
->gl_ops
.ext
.p_glTexImage3DEXT
= (void *)gl_info
->gl_ops
.ext
.p_glTexImage3D
;
2816 gl_info
->gl_ops
.ext
.p_glTexSubImage3DEXT
= gl_info
->gl_ops
.ext
.p_glTexSubImage3D
;
2817 gl_info
->supported
[EXT_TEXTURE3D
] = TRUE
;
2820 if (!gl_info
->supported
[NV_POINT_SPRITE
] && gl_version
>= MAKEDWORD_VERSION(1, 4))
2822 TRACE("GL CORE: GL_NV_point_sprite support.\n");
2823 gl_info
->gl_ops
.ext
.p_glPointParameterivNV
= gl_info
->gl_ops
.ext
.p_glPointParameteriv
;
2824 gl_info
->gl_ops
.ext
.p_glPointParameteriNV
= gl_info
->gl_ops
.ext
.p_glPointParameteri
;
2825 gl_info
->supported
[NV_POINT_SPRITE
] = TRUE
;
2828 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] && gl_version
>= MAKEDWORD_VERSION(2, 0))
2830 TRACE("GL CORE: GL_ARB_texture_non_power_of_two support.\n");
2831 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = TRUE
;
2834 if (gl_version
>= MAKEDWORD_VERSION(2, 0)) gl_info
->supported
[WINED3D_GL_VERSION_2_0
] = TRUE
;
2836 if (gl_info
->supported
[APPLE_FENCE
])
2838 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
2839 * The apple extension interacts with some other apple exts. Disable the NV
2840 * extension if the apple one is support to prevent confusion in other parts
2842 gl_info
->supported
[NV_FENCE
] = FALSE
;
2844 if (gl_info
->supported
[APPLE_FLOAT_PIXELS
])
2846 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
2848 * The enums are the same:
2849 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881a
2850 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881b
2851 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
2852 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
2853 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140b
2855 if (!gl_info
->supported
[ARB_TEXTURE_FLOAT
])
2857 TRACE(" IMPLIED: GL_ARB_texture_float support (by GL_APPLE_float_pixels).\n");
2858 gl_info
->supported
[ARB_TEXTURE_FLOAT
] = TRUE
;
2860 if (!gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
2862 TRACE(" IMPLIED: GL_ARB_half_float_pixel support (by GL_APPLE_float_pixels).\n");
2863 gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
] = TRUE
;
2866 if (gl_info
->supported
[ARB_MAP_BUFFER_RANGE
])
2868 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
2869 * functionality. Prefer the ARB extension */
2870 gl_info
->supported
[APPLE_FLUSH_BUFFER_RANGE
] = FALSE
;
2872 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
2874 TRACE(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
2875 gl_info
->supported
[NV_TEXGEN_REFLECTION
] = TRUE
;
2877 if (!gl_info
->supported
[ARB_DEPTH_CLAMP
] && gl_info
->supported
[NV_DEPTH_CLAMP
])
2879 TRACE(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
2880 gl_info
->supported
[ARB_DEPTH_CLAMP
] = TRUE
;
2882 if (!gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] && gl_info
->supported
[EXT_VERTEX_ARRAY_BGRA
])
2884 TRACE(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
2885 gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
] = TRUE
;
2887 if (!gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] && gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
])
2889 TRACE(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
2890 gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] = TRUE
;
2892 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
2894 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2896 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
2897 * are supported. The nv extensions provide the same functionality as the
2898 * ATI one, and a bit more(signed pixelformats). */
2899 gl_info
->supported
[ATI_FRAGMENT_SHADER
] = FALSE
;
2902 if (gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
2904 /* If we have full NP2 texture support, disable
2905 * GL_ARB_texture_rectangle because we will never use it.
2906 * This saves a few redundant glDisable calls. */
2907 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = FALSE
;
2909 if (gl_info
->supported
[ATI_FRAGMENT_SHADER
])
2911 /* Disable NV_register_combiners and fragment shader if this is supported.
2912 * generally the NV extensions are preferred over the ATI ones, and this
2913 * extension is disabled if register_combiners and texture_shader2 are both
2914 * supported. So we reach this place only if we have incomplete NV dxlevel 8
2915 * fragment processing support. */
2916 gl_info
->supported
[NV_REGISTER_COMBINERS
] = FALSE
;
2917 gl_info
->supported
[NV_REGISTER_COMBINERS2
] = FALSE
;
2918 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
2919 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
2921 if (gl_info
->supported
[NV_HALF_FLOAT
])
2923 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
2924 gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
] = TRUE
;
2926 if (gl_info
->supported
[ARB_FRAMEBUFFER_SRGB
] && !gl_info
->supported
[EXT_TEXTURE_SRGB_DECODE
])
2928 /* Current wined3d sRGB infrastructure requires EXT_texture_sRGB_decode
2929 * for GL_ARB_framebuffer_sRGB support (without EXT_texture_sRGB_decode
2930 * we never render to sRGB surfaces). */
2931 gl_info
->supported
[ARB_FRAMEBUFFER_SRGB
] = FALSE
;
2933 if (gl_info
->supported
[ARB_OCCLUSION_QUERY
])
2937 GL_EXTCALL(glGetQueryivARB(GL_SAMPLES_PASSED_ARB
, GL_QUERY_COUNTER_BITS_ARB
, &counter_bits
));
2938 TRACE("Occlusion query counter has %d bits.\n", counter_bits
);
2940 gl_info
->supported
[ARB_OCCLUSION_QUERY
] = FALSE
;
2942 if (!gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] && gl_info
->supported
[EXT_TEXTURE_MIRROR_CLAMP
])
2944 TRACE(" IMPLIED: ATI_texture_mirror_once support (by EXT_texture_mirror_clamp).\n");
2945 gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] = TRUE
;
2947 if (!gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
] && gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
2949 TRACE(" IMPLIED: ARB_texture_mirror_clamp_to_edge support (by ATI_texture_mirror_once).\n");
2950 gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
] = TRUE
;
2953 wined3d_adapter_init_limits(gl_info
);
2955 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
] && test_arb_vs_offset_limit(gl_info
))
2956 gl_info
->quirks
|= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT
;
2958 if (gl_info
->supported
[ARB_SHADING_LANGUAGE_100
])
2960 const char *str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_SHADING_LANGUAGE_VERSION_ARB
);
2961 unsigned int major
, minor
;
2963 TRACE("GLSL version string: %s.\n", debugstr_a(str
));
2965 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
2966 sscanf(str
, "%u.%u", &major
, &minor
);
2967 gl_info
->glsl_version
= MAKEDWORD_VERSION(major
, minor
);
2970 checkGLcall("extension detection");
2972 adapter
->shader_backend
= select_shader_backend(gl_info
);
2973 adapter
->vertex_pipe
= select_vertex_implementation(gl_info
, adapter
->shader_backend
);
2974 adapter
->fragment_pipe
= select_fragment_implementation(gl_info
, adapter
->shader_backend
);
2975 adapter
->blitter
= select_blit_implementation(gl_info
, adapter
->shader_backend
);
2977 adapter
->shader_backend
->shader_get_caps(&adapter
->gl_info
, &shader_caps
);
2978 adapter
->d3d_info
.vs_clipping
= shader_caps
.wined3d_caps
& WINED3D_SHADER_CAP_VS_CLIPPING
;
2979 adapter
->d3d_info
.limits
.vs_version
= shader_caps
.vs_version
;
2980 adapter
->d3d_info
.limits
.gs_version
= shader_caps
.gs_version
;
2981 adapter
->d3d_info
.limits
.ps_version
= shader_caps
.ps_version
;
2982 adapter
->d3d_info
.limits
.vs_uniform_count
= shader_caps
.vs_uniform_count
;
2983 adapter
->d3d_info
.limits
.ps_uniform_count
= shader_caps
.ps_uniform_count
;
2985 adapter
->vertex_pipe
->vp_get_caps(gl_info
, &vertex_caps
);
2986 adapter
->d3d_info
.xyzrhw
= vertex_caps
.xyzrhw
;
2988 adapter
->fragment_pipe
->get_caps(gl_info
, &fragment_caps
);
2989 adapter
->d3d_info
.limits
.ffp_blend_stages
= fragment_caps
.MaxTextureBlendStages
;
2990 adapter
->d3d_info
.limits
.ffp_textures
= fragment_caps
.MaxSimultaneousTextures
;
2991 TRACE("Max texture stages: %u.\n", adapter
->d3d_info
.limits
.ffp_blend_stages
);
2993 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
2995 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->gl_ops
.ext
.p_glIsRenderbuffer
;
2996 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->gl_ops
.ext
.p_glBindRenderbuffer
;
2997 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->gl_ops
.ext
.p_glDeleteRenderbuffers
;
2998 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->gl_ops
.ext
.p_glGenRenderbuffers
;
2999 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->gl_ops
.ext
.p_glRenderbufferStorage
;
3000 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->gl_ops
.ext
.p_glRenderbufferStorageMultisample
;
3001 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->gl_ops
.ext
.p_glGetRenderbufferParameteriv
;
3002 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->gl_ops
.ext
.p_glIsFramebuffer
;
3003 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->gl_ops
.ext
.p_glBindFramebuffer
;
3004 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->gl_ops
.ext
.p_glDeleteFramebuffers
;
3005 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->gl_ops
.ext
.p_glGenFramebuffers
;
3006 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->gl_ops
.ext
.p_glCheckFramebufferStatus
;
3007 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture1D
;
3008 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture2D
;
3009 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture3D
;
3010 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->gl_ops
.ext
.p_glFramebufferRenderbuffer
;
3011 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
3012 = gl_info
->gl_ops
.ext
.p_glGetFramebufferAttachmentParameteriv
;
3013 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->gl_ops
.ext
.p_glBlitFramebuffer
;
3014 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->gl_ops
.ext
.p_glGenerateMipmap
;
3018 if (gl_info
->supported
[EXT_FRAMEBUFFER_OBJECT
])
3020 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->gl_ops
.ext
.p_glIsRenderbufferEXT
;
3021 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->gl_ops
.ext
.p_glBindRenderbufferEXT
;
3022 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->gl_ops
.ext
.p_glDeleteRenderbuffersEXT
;
3023 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->gl_ops
.ext
.p_glGenRenderbuffersEXT
;
3024 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->gl_ops
.ext
.p_glRenderbufferStorageEXT
;
3025 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->gl_ops
.ext
.p_glGetRenderbufferParameterivEXT
;
3026 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->gl_ops
.ext
.p_glIsFramebufferEXT
;
3027 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->gl_ops
.ext
.p_glBindFramebufferEXT
;
3028 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->gl_ops
.ext
.p_glDeleteFramebuffersEXT
;
3029 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->gl_ops
.ext
.p_glGenFramebuffersEXT
;
3030 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->gl_ops
.ext
.p_glCheckFramebufferStatusEXT
;
3031 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture1DEXT
;
3032 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture2DEXT
;
3033 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture3DEXT
;
3034 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->gl_ops
.ext
.p_glFramebufferRenderbufferEXT
;
3035 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
3036 = gl_info
->gl_ops
.ext
.p_glGetFramebufferAttachmentParameterivEXT
;
3037 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->gl_ops
.ext
.p_glGenerateMipmapEXT
;
3039 else if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3041 WARN_(d3d_perf
)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
3042 wined3d_settings
.offscreen_rendering_mode
= ORM_BACKBUFFER
;
3044 if (gl_info
->supported
[EXT_FRAMEBUFFER_BLIT
])
3046 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->gl_ops
.ext
.p_glBlitFramebufferEXT
;
3048 if (gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
3050 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
3051 = gl_info
->gl_ops
.ext
.p_glRenderbufferStorageMultisampleEXT
;
3055 gl_vendor
= wined3d_guess_gl_vendor(gl_info
, gl_vendor_str
, gl_renderer_str
);
3056 card_vendor
= wined3d_guess_card_vendor(gl_vendor_str
, gl_renderer_str
);
3057 TRACE("Found GL_VENDOR (%s)->(0x%04x/0x%04x).\n", debugstr_a(gl_vendor_str
), gl_vendor
, card_vendor
);
3059 device
= wined3d_guess_card(gl_info
, gl_renderer_str
, &gl_vendor
, &card_vendor
);
3060 TRACE("Found (fake) card: 0x%x (vendor id), 0x%x (device id).\n", card_vendor
, device
);
3062 gl_info
->wrap_lookup
[WINED3D_TADDRESS_WRAP
- WINED3D_TADDRESS_WRAP
] = GL_REPEAT
;
3063 gl_info
->wrap_lookup
[WINED3D_TADDRESS_MIRROR
- WINED3D_TADDRESS_WRAP
] =
3064 gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
] ? GL_MIRRORED_REPEAT_ARB
: GL_REPEAT
;
3065 gl_info
->wrap_lookup
[WINED3D_TADDRESS_CLAMP
- WINED3D_TADDRESS_WRAP
] = GL_CLAMP_TO_EDGE
;
3066 gl_info
->wrap_lookup
[WINED3D_TADDRESS_BORDER
- WINED3D_TADDRESS_WRAP
] =
3067 gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
] ? GL_CLAMP_TO_BORDER_ARB
: GL_REPEAT
;
3068 gl_info
->wrap_lookup
[WINED3D_TADDRESS_MIRROR_ONCE
- WINED3D_TADDRESS_WRAP
] =
3069 gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
] ? GL_MIRROR_CLAMP_TO_EDGE
: GL_REPEAT
;
3071 adapter
->d3d_info
.valid_rt_mask
= 0;
3072 for (i
= 0; i
< gl_info
->limits
.buffers
; ++i
)
3073 adapter
->d3d_info
.valid_rt_mask
|= (1 << i
);
3075 fixup_extensions(gl_info
, gl_renderer_str
, gl_vendor
, card_vendor
, device
);
3076 init_driver_info(driver_info
, card_vendor
, device
);
3077 add_gl_compat_wrappers(gl_info
);
3082 UINT CDECL
wined3d_get_adapter_count(const struct wined3d
*wined3d
)
3084 TRACE("wined3d %p, reporting %u adapters.\n",
3085 wined3d
, wined3d
->adapter_count
);
3087 return wined3d
->adapter_count
;
3090 HRESULT CDECL
wined3d_register_software_device(struct wined3d
*wined3d
, void *init_function
)
3092 FIXME("wined3d %p, init_function %p stub!\n", wined3d
, init_function
);
3097 HMONITOR CDECL
wined3d_get_adapter_monitor(const struct wined3d
*wined3d
, UINT adapter_idx
)
3099 TRACE("wined3d %p, adapter_idx %u.\n", wined3d
, adapter_idx
);
3101 if (adapter_idx
>= wined3d
->adapter_count
)
3104 return MonitorFromPoint(wined3d
->adapters
[adapter_idx
].monitorPoint
, MONITOR_DEFAULTTOPRIMARY
);
3107 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
3108 of the same bpp but different resolutions */
3110 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
3111 UINT CDECL
wined3d_get_adapter_mode_count(const struct wined3d
*wined3d
, UINT adapter_idx
,
3112 enum wined3d_format_id format_id
, enum wined3d_scanline_ordering scanline_ordering
)
3114 const struct wined3d_adapter
*adapter
;
3115 const struct wined3d_format
*format
;
3121 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x.\n",
3122 wined3d
, adapter_idx
, debug_d3dformat(format_id
), scanline_ordering
);
3124 if (adapter_idx
>= wined3d
->adapter_count
)
3127 adapter
= &wined3d
->adapters
[adapter_idx
];
3128 format
= wined3d_get_format(&adapter
->gl_info
, format_id
);
3129 format_bits
= format
->byte_count
* CHAR_BIT
;
3131 memset(&mode
, 0, sizeof(mode
));
3132 mode
.dmSize
= sizeof(mode
);
3134 while (EnumDisplaySettingsExW(adapter
->DeviceName
, j
++, &mode
, 0))
3136 if (mode
.dmFields
& DM_DISPLAYFLAGS
)
3138 if (scanline_ordering
== WINED3D_SCANLINE_ORDERING_PROGRESSIVE
3139 && (mode
.u2
.dmDisplayFlags
& DM_INTERLACED
))
3142 if (scanline_ordering
== WINED3D_SCANLINE_ORDERING_INTERLACED
3143 && !(mode
.u2
.dmDisplayFlags
& DM_INTERLACED
))
3147 if (format_id
== WINED3DFMT_UNKNOWN
)
3149 /* This is for d3d8, do not enumerate P8 here. */
3150 if (mode
.dmBitsPerPel
== 32 || mode
.dmBitsPerPel
== 16) ++i
;
3152 else if (mode
.dmBitsPerPel
== format_bits
)
3158 TRACE("Returning %u matching modes (out of %u total) for adapter %u.\n", i
, j
, adapter_idx
);
3163 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
3164 HRESULT CDECL
wined3d_enum_adapter_modes(const struct wined3d
*wined3d
, UINT adapter_idx
,
3165 enum wined3d_format_id format_id
, enum wined3d_scanline_ordering scanline_ordering
,
3166 UINT mode_idx
, struct wined3d_display_mode
*mode
)
3168 const struct wined3d_adapter
*adapter
;
3169 const struct wined3d_format
*format
;
3175 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x, mode_idx %u, mode %p.\n",
3176 wined3d
, adapter_idx
, debug_d3dformat(format_id
), scanline_ordering
, mode_idx
, mode
);
3178 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
)
3179 return WINED3DERR_INVALIDCALL
;
3181 adapter
= &wined3d
->adapters
[adapter_idx
];
3182 format
= wined3d_get_format(&adapter
->gl_info
, format_id
);
3183 format_bits
= format
->byte_count
* CHAR_BIT
;
3185 memset(&m
, 0, sizeof(m
));
3186 m
.dmSize
= sizeof(m
);
3188 while (i
<= mode_idx
)
3190 if (!EnumDisplaySettingsExW(adapter
->DeviceName
, j
++, &m
, 0))
3192 WARN("Invalid mode_idx %u.\n", mode_idx
);
3193 return WINED3DERR_INVALIDCALL
;
3196 if (m
.dmFields
& DM_DISPLAYFLAGS
)
3198 if (scanline_ordering
== WINED3D_SCANLINE_ORDERING_PROGRESSIVE
3199 && (m
.u2
.dmDisplayFlags
& DM_INTERLACED
))
3202 if (scanline_ordering
== WINED3D_SCANLINE_ORDERING_INTERLACED
3203 && !(m
.u2
.dmDisplayFlags
& DM_INTERLACED
))
3207 if (format_id
== WINED3DFMT_UNKNOWN
)
3209 /* This is for d3d8, do not enumerate P8 here. */
3210 if (m
.dmBitsPerPel
== 32 || m
.dmBitsPerPel
== 16) ++i
;
3212 else if (m
.dmBitsPerPel
== format_bits
)
3218 mode
->width
= m
.dmPelsWidth
;
3219 mode
->height
= m
.dmPelsHeight
;
3220 mode
->refresh_rate
= DEFAULT_REFRESH_RATE
;
3221 if (m
.dmFields
& DM_DISPLAYFREQUENCY
)
3222 mode
->refresh_rate
= m
.dmDisplayFrequency
;
3224 if (format_id
== WINED3DFMT_UNKNOWN
)
3225 mode
->format_id
= pixelformat_for_depth(m
.dmBitsPerPel
);
3227 mode
->format_id
= format_id
;
3229 if (!(m
.dmFields
& DM_DISPLAYFLAGS
))
3230 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_UNKNOWN
;
3231 else if (m
.u2
.dmDisplayFlags
& DM_INTERLACED
)
3232 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_INTERLACED
;
3234 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_PROGRESSIVE
;
3236 TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode
->width
, mode
->height
, mode
->refresh_rate
,
3237 m
.dmBitsPerPel
, debug_d3dformat(mode
->format_id
), mode
->scanline_ordering
);
3242 HRESULT CDECL
wined3d_get_adapter_display_mode(const struct wined3d
*wined3d
, UINT adapter_idx
,
3243 struct wined3d_display_mode
*mode
, enum wined3d_display_rotation
*rotation
)
3245 const struct wined3d_adapter
*adapter
;
3248 TRACE("wined3d %p, adapter_idx %u, display_mode %p, rotation %p.\n",
3249 wined3d
, adapter_idx
, mode
, rotation
);
3251 if (!mode
|| adapter_idx
>= wined3d
->adapter_count
)
3252 return WINED3DERR_INVALIDCALL
;
3254 adapter
= &wined3d
->adapters
[adapter_idx
];
3256 memset(&m
, 0, sizeof(m
));
3257 m
.dmSize
= sizeof(m
);
3259 EnumDisplaySettingsExW(adapter
->DeviceName
, ENUM_CURRENT_SETTINGS
, &m
, 0);
3260 mode
->width
= m
.dmPelsWidth
;
3261 mode
->height
= m
.dmPelsHeight
;
3262 mode
->refresh_rate
= DEFAULT_REFRESH_RATE
;
3263 if (m
.dmFields
& DM_DISPLAYFREQUENCY
)
3264 mode
->refresh_rate
= m
.dmDisplayFrequency
;
3265 mode
->format_id
= pixelformat_for_depth(m
.dmBitsPerPel
);
3267 /* Lie about the format. X11 can't change the color depth, and some apps
3268 * are pretty angry if they SetDisplayMode from 24 to 16 bpp and find out
3269 * that GetDisplayMode still returns 24 bpp. This should probably be
3270 * handled in winex11 instead. */
3271 if (adapter
->screen_format
&& adapter
->screen_format
!= mode
->format_id
)
3273 WARN("Overriding format %s with stored format %s.\n",
3274 debug_d3dformat(mode
->format_id
),
3275 debug_d3dformat(adapter
->screen_format
));
3276 mode
->format_id
= adapter
->screen_format
;
3279 if (!(m
.dmFields
& DM_DISPLAYFLAGS
))
3280 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_UNKNOWN
;
3281 else if (m
.u2
.dmDisplayFlags
& DM_INTERLACED
)
3282 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_INTERLACED
;
3284 mode
->scanline_ordering
= WINED3D_SCANLINE_ORDERING_PROGRESSIVE
;
3288 switch (m
.u1
.s2
.dmDisplayOrientation
)
3291 *rotation
= WINED3D_DISPLAY_ROTATION_0
;
3294 *rotation
= WINED3D_DISPLAY_ROTATION_90
;
3297 *rotation
= WINED3D_DISPLAY_ROTATION_180
;
3300 *rotation
= WINED3D_DISPLAY_ROTATION_270
;
3303 FIXME("Unhandled display rotation %#x.\n", m
.u1
.s2
.dmDisplayOrientation
);
3304 *rotation
= WINED3D_DISPLAY_ROTATION_UNSPECIFIED
;
3309 TRACE("Returning %ux%u@%u %s %#x.\n", mode
->width
, mode
->height
,
3310 mode
->refresh_rate
, debug_d3dformat(mode
->format_id
),
3311 mode
->scanline_ordering
);
3315 HRESULT CDECL
wined3d_set_adapter_display_mode(struct wined3d
*wined3d
,
3316 UINT adapter_idx
, const struct wined3d_display_mode
*mode
)
3318 struct wined3d_display_mode current_mode
;
3319 const struct wined3d_format
*format
;
3320 struct wined3d_adapter
*adapter
;
3326 TRACE("wined3d %p, adapter_idx %u, mode %p (%ux%u@%u %s %#x).\n", wined3d
, adapter_idx
, mode
,
3327 mode
->width
, mode
->height
, mode
->refresh_rate
, debug_d3dformat(mode
->format_id
),
3328 mode
->scanline_ordering
);
3330 if (adapter_idx
>= wined3d
->adapter_count
)
3331 return WINED3DERR_INVALIDCALL
;
3333 adapter
= &wined3d
->adapters
[adapter_idx
];
3334 format
= wined3d_get_format(&adapter
->gl_info
, mode
->format_id
);
3336 memset(&devmode
, 0, sizeof(devmode
));
3337 devmode
.dmSize
= sizeof(devmode
);
3338 devmode
.dmFields
= DM_BITSPERPEL
| DM_PELSWIDTH
| DM_PELSHEIGHT
;
3339 devmode
.dmBitsPerPel
= format
->byte_count
* CHAR_BIT
;
3340 devmode
.dmPelsWidth
= mode
->width
;
3341 devmode
.dmPelsHeight
= mode
->height
;
3343 devmode
.dmDisplayFrequency
= mode
->refresh_rate
;
3344 if (mode
->refresh_rate
)
3345 devmode
.dmFields
|= DM_DISPLAYFREQUENCY
;
3347 if (mode
->scanline_ordering
!= WINED3D_SCANLINE_ORDERING_UNKNOWN
)
3349 devmode
.dmFields
|= DM_DISPLAYFLAGS
;
3350 if (mode
->scanline_ordering
== WINED3D_SCANLINE_ORDERING_INTERLACED
)
3351 devmode
.u2
.dmDisplayFlags
|= DM_INTERLACED
;
3354 /* Only change the mode if necessary. */
3355 if (FAILED(hr
= wined3d_get_adapter_display_mode(wined3d
, adapter_idx
, ¤t_mode
, NULL
)))
3357 ERR("Failed to get current display mode, hr %#x.\n", hr
);
3359 else if (current_mode
.width
== mode
->width
3360 && current_mode
.height
== mode
->height
3361 && current_mode
.format_id
== mode
->format_id
3362 && (current_mode
.refresh_rate
== mode
->refresh_rate
3363 || !mode
->refresh_rate
)
3364 && (current_mode
.scanline_ordering
== mode
->scanline_ordering
3365 || mode
->scanline_ordering
== WINED3D_SCANLINE_ORDERING_UNKNOWN
))
3367 TRACE("Skipping redundant mode setting call.\n");
3371 ret
= ChangeDisplaySettingsExW(adapter
->DeviceName
, &devmode
, NULL
, CDS_FULLSCREEN
, NULL
);
3372 if (ret
!= DISP_CHANGE_SUCCESSFUL
)
3374 if (devmode
.dmDisplayFrequency
)
3376 WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate.\n");
3377 devmode
.dmFields
&= ~DM_DISPLAYFREQUENCY
;
3378 devmode
.dmDisplayFrequency
= 0;
3379 ret
= ChangeDisplaySettingsExW(adapter
->DeviceName
, &devmode
, NULL
, CDS_FULLSCREEN
, NULL
);
3381 if (ret
!= DISP_CHANGE_SUCCESSFUL
)
3382 return WINED3DERR_NOTAVAILABLE
;
3385 /* Store the new values. */
3386 adapter
->screen_format
= mode
->format_id
;
3388 /* And finally clip mouse to our screen. */
3389 SetRect(&clip_rc
, 0, 0, mode
->width
, mode
->height
);
3390 ClipCursor(&clip_rc
);
3395 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
3396 and fields being inserted in the middle, a new structure is used in place */
3397 HRESULT CDECL
wined3d_get_adapter_identifier(const struct wined3d
*wined3d
,
3398 UINT adapter_idx
, DWORD flags
, struct wined3d_adapter_identifier
*identifier
)
3400 const struct wined3d_adapter
*adapter
;
3403 TRACE("wined3d %p, adapter_idx %u, flags %#x, identifier %p.\n",
3404 wined3d
, adapter_idx
, flags
, identifier
);
3406 if (adapter_idx
>= wined3d
->adapter_count
)
3407 return WINED3DERR_INVALIDCALL
;
3409 adapter
= &wined3d
->adapters
[adapter_idx
];
3411 if (identifier
->driver_size
)
3413 const char *name
= adapter
->driver_info
.name
;
3414 len
= min(strlen(name
), identifier
->driver_size
- 1);
3415 memcpy(identifier
->driver
, name
, len
);
3416 identifier
->driver
[len
] = '\0';
3419 if (identifier
->description_size
)
3421 const char *description
= adapter
->driver_info
.description
;
3422 len
= min(strlen(description
), identifier
->description_size
- 1);
3423 memcpy(identifier
->description
, description
, len
);
3424 identifier
->description
[len
] = '\0';
3427 /* Note that d3d8 doesn't supply a device name. */
3428 if (identifier
->device_name_size
)
3430 if (!WideCharToMultiByte(CP_ACP
, 0, adapter
->DeviceName
, -1, identifier
->device_name
,
3431 identifier
->device_name_size
, NULL
, NULL
))
3433 ERR("Failed to convert device name, last error %#x.\n", GetLastError());
3434 return WINED3DERR_INVALIDCALL
;
3438 identifier
->driver_version
.u
.HighPart
= adapter
->driver_info
.version_high
;
3439 identifier
->driver_version
.u
.LowPart
= adapter
->driver_info
.version_low
;
3440 identifier
->vendor_id
= adapter
->driver_info
.vendor
;
3441 identifier
->device_id
= adapter
->driver_info
.device
;
3442 identifier
->subsystem_id
= 0;
3443 identifier
->revision
= 0;
3444 memcpy(&identifier
->device_identifier
, &IID_D3DDEVICE_D3DUID
, sizeof(identifier
->device_identifier
));
3445 identifier
->whql_level
= (flags
& WINED3DENUM_NO_WHQL_LEVEL
) ? 0 : 1;
3446 memcpy(&identifier
->adapter_luid
, &adapter
->luid
, sizeof(identifier
->adapter_luid
));
3447 identifier
->video_memory
= adapter
->TextureRam
;
3452 HRESULT CDECL
wined3d_get_adapter_raster_status(const struct wined3d
*wined3d
, UINT adapter_idx
,
3453 struct wined3d_raster_status
*raster_status
)
3455 LONGLONG freq_per_frame
, freq_per_line
;
3456 LARGE_INTEGER counter
, freq_per_sec
;
3457 struct wined3d_display_mode mode
;
3461 FIXME("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
3462 wined3d
, adapter_idx
, raster_status
);
3464 WARN("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
3465 wined3d
, adapter_idx
, raster_status
);
3467 /* Obtaining the raster status is a widely implemented but optional
3468 * feature. When this method returns OK StarCraft 2 expects the
3469 * raster_status->InVBlank value to actually change over time.
3470 * And Endless Alice Crysis doesn't care even if this method fails.
3471 * Thus this method returns OK and fakes raster_status by
3472 * QueryPerformanceCounter. */
3474 if (!QueryPerformanceCounter(&counter
) || !QueryPerformanceFrequency(&freq_per_sec
))
3475 return WINED3DERR_INVALIDCALL
;
3476 if (FAILED(wined3d_get_adapter_display_mode(wined3d
, adapter_idx
, &mode
, NULL
)))
3477 return WINED3DERR_INVALIDCALL
;
3478 if (mode
.refresh_rate
== DEFAULT_REFRESH_RATE
)
3479 mode
.refresh_rate
= 60;
3481 freq_per_frame
= freq_per_sec
.QuadPart
/ mode
.refresh_rate
;
3482 /* Assume 20 scan lines in the vertical blank. */
3483 freq_per_line
= freq_per_frame
/ (mode
.height
+ 20);
3484 raster_status
->scan_line
= (counter
.QuadPart
% freq_per_frame
) / freq_per_line
;
3485 if (raster_status
->scan_line
< mode
.height
)
3486 raster_status
->in_vblank
= FALSE
;
3489 raster_status
->scan_line
= 0;
3490 raster_status
->in_vblank
= TRUE
;
3493 TRACE("Returning fake value, in_vblank %u, scan_line %u.\n",
3494 raster_status
->in_vblank
, raster_status
->scan_line
);
3499 static BOOL
wined3d_check_pixel_format_color(const struct wined3d_gl_info
*gl_info
,
3500 const struct wined3d_pixel_format
*cfg
, const struct wined3d_format
*format
)
3502 BYTE redSize
, greenSize
, blueSize
, alphaSize
, colorBits
;
3504 /* Float formats need FBOs. If FBOs are used this function isn't called */
3505 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
3507 if(cfg
->iPixelType
== WGL_TYPE_RGBA_ARB
) { /* Integer RGBA formats */
3508 if (!getColorBits(format
, &redSize
, &greenSize
, &blueSize
, &alphaSize
, &colorBits
))
3510 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
3514 if(cfg
->redSize
< redSize
)
3517 if(cfg
->greenSize
< greenSize
)
3520 if(cfg
->blueSize
< blueSize
)
3523 if(cfg
->alphaSize
< alphaSize
)
3529 /* Probably a RGBA_float or color index mode */
3533 static BOOL
wined3d_check_pixel_format_depth(const struct wined3d_gl_info
*gl_info
,
3534 const struct wined3d_pixel_format
*cfg
, const struct wined3d_format
*format
)
3536 BYTE depthSize
, stencilSize
;
3537 BOOL lockable
= FALSE
;
3539 if (!getDepthStencilBits(format
, &depthSize
, &stencilSize
))
3541 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format
->id
));
3545 /* Float formats need FBOs. If FBOs are used this function isn't called */
3546 if (format
->flags
& WINED3DFMT_FLAG_FLOAT
) return FALSE
;
3548 if ((format
->id
== WINED3DFMT_D16_LOCKABLE
) || (format
->id
== WINED3DFMT_D32_FLOAT
))
3551 /* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports.
3552 * We can safely report 'compatible' formats (e.g. D24 can be used for D16) as long as we aren't dealing with
3553 * a lockable format. This also helps D3D <= 7 as they expect D16 which isn't offered without this on Geforce8 cards. */
3554 if(!(cfg
->depthSize
== depthSize
|| (!lockable
&& cfg
->depthSize
> depthSize
)))
3557 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
3558 * allow more stencil bits than requested. */
3559 if(cfg
->stencilSize
< stencilSize
)
3565 HRESULT CDECL
wined3d_check_depth_stencil_match(const struct wined3d
*wined3d
,
3566 UINT adapter_idx
, enum wined3d_device_type device_type
, enum wined3d_format_id adapter_format_id
,
3567 enum wined3d_format_id render_target_format_id
, enum wined3d_format_id depth_stencil_format_id
)
3569 const struct wined3d_format
*rt_format
;
3570 const struct wined3d_format
*ds_format
;
3571 const struct wined3d_adapter
*adapter
;
3573 TRACE("wined3d %p, adapter_idx %u, device_type %s,\n"
3574 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
3575 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3576 debug_d3dformat(render_target_format_id
), debug_d3dformat(depth_stencil_format_id
));
3578 if (adapter_idx
>= wined3d
->adapter_count
)
3579 return WINED3DERR_INVALIDCALL
;
3581 adapter
= &wined3d
->adapters
[adapter_idx
];
3582 rt_format
= wined3d_get_format(&adapter
->gl_info
, render_target_format_id
);
3583 ds_format
= wined3d_get_format(&adapter
->gl_info
, depth_stencil_format_id
);
3584 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3586 if ((rt_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)
3587 && (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)))
3589 TRACE("Formats match.\n");
3595 const struct wined3d_pixel_format
*cfgs
;
3596 unsigned int cfg_count
;
3599 cfgs
= adapter
->cfgs
;
3600 cfg_count
= adapter
->cfg_count
;
3601 for (i
= 0; i
< cfg_count
; ++i
)
3603 if (wined3d_check_pixel_format_color(&adapter
->gl_info
, &cfgs
[i
], rt_format
)
3604 && wined3d_check_pixel_format_depth(&adapter
->gl_info
, &cfgs
[i
], ds_format
))
3606 TRACE("Formats match.\n");
3612 TRACE("Unsupported format pair: %s and %s.\n",
3613 debug_d3dformat(render_target_format_id
),
3614 debug_d3dformat(depth_stencil_format_id
));
3616 return WINED3DERR_NOTAVAILABLE
;
3619 HRESULT CDECL
wined3d_check_device_multisample_type(const struct wined3d
*wined3d
, UINT adapter_idx
,
3620 enum wined3d_device_type device_type
, enum wined3d_format_id surface_format_id
, BOOL windowed
,
3621 enum wined3d_multisample_type multisample_type
, DWORD
*quality_levels
)
3623 const struct wined3d_gl_info
*gl_info
;
3625 TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s,\n"
3626 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
3627 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(surface_format_id
),
3628 windowed
, multisample_type
, quality_levels
);
3630 if (adapter_idx
>= wined3d
->adapter_count
)
3631 return WINED3DERR_INVALIDCALL
;
3633 gl_info
= &wined3d
->adapters
[adapter_idx
].gl_info
;
3635 if (multisample_type
> gl_info
->limits
.samples
)
3637 TRACE("Returning not supported.\n");
3639 *quality_levels
= 0;
3641 return WINED3DERR_NOTAVAILABLE
;
3646 if (multisample_type
== WINED3D_MULTISAMPLE_NON_MASKABLE
)
3647 /* FIXME: This is probably wrong. */
3648 *quality_levels
= gl_info
->limits
.samples
;
3650 *quality_levels
= 1;
3656 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
3657 static BOOL
CheckDepthStencilCapability(const struct wined3d_adapter
*adapter
,
3658 const struct wined3d_format
*display_format
, const struct wined3d_format
*ds_format
)
3660 /* Only allow depth/stencil formats */
3661 if (!(ds_format
->depth_size
|| ds_format
->stencil_size
)) return FALSE
;
3663 /* Blacklist formats not supported on Windows */
3664 switch (ds_format
->id
)
3666 case WINED3DFMT_S1_UINT_D15_UNORM
: /* Breaks the shadowvol2 dx7 sdk sample */
3667 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
3668 TRACE("[FAILED] - not supported on windows.\n");
3675 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3677 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
3678 if (ds_format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
)) return TRUE
;
3684 /* Walk through all WGL pixel formats to find a match */
3685 for (i
= 0; i
< adapter
->cfg_count
; ++i
)
3687 const struct wined3d_pixel_format
*cfg
= &adapter
->cfgs
[i
];
3688 if (wined3d_check_pixel_format_color(&adapter
->gl_info
, cfg
, display_format
)
3689 && wined3d_check_pixel_format_depth(&adapter
->gl_info
, cfg
, ds_format
))
3697 /* Check the render target capabilities of a format */
3698 static BOOL
CheckRenderTargetCapability(const struct wined3d_adapter
*adapter
,
3699 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*check_format
)
3701 /* Filter out non-RT formats */
3702 if (!(check_format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)) return FALSE
;
3703 if (wined3d_settings
.offscreen_rendering_mode
== ORM_BACKBUFFER
)
3705 BYTE AdapterRed
, AdapterGreen
, AdapterBlue
, AdapterAlpha
, AdapterTotalSize
;
3706 BYTE CheckRed
, CheckGreen
, CheckBlue
, CheckAlpha
, CheckTotalSize
;
3707 const struct wined3d_pixel_format
*cfgs
= adapter
->cfgs
;
3710 getColorBits(adapter_format
, &AdapterRed
, &AdapterGreen
, &AdapterBlue
, &AdapterAlpha
, &AdapterTotalSize
);
3711 getColorBits(check_format
, &CheckRed
, &CheckGreen
, &CheckBlue
, &CheckAlpha
, &CheckTotalSize
);
3713 /* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
3714 * The format must match in RGB, alpha is allowed to be different. (Only the backbuffer can have alpha) */
3715 if (!((AdapterRed
== CheckRed
) && (AdapterGreen
== CheckGreen
) && (AdapterBlue
== CheckBlue
)))
3717 TRACE("[FAILED]\n");
3721 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
3722 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
3723 for (i
= 0; i
< adapter
->cfg_count
; ++i
)
3725 if (cfgs
[i
].windowDrawable
3726 && wined3d_check_pixel_format_color(&adapter
->gl_info
, &cfgs
[i
], check_format
))
3728 TRACE("Pixel format %d is compatible with format %s.\n",
3729 cfgs
[i
].iPixelFormat
, debug_d3dformat(check_format
->id
));
3734 else if(wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3736 /* For now return TRUE for FBOs until we have some proper checks.
3737 * Note that this function will only be called when the format is around for texturing. */
3743 static BOOL
CheckSurfaceCapability(const struct wined3d_adapter
*adapter
,
3744 const struct wined3d_format
*adapter_format
,
3745 const struct wined3d_format
*check_format
, BOOL no3d
)
3749 switch (check_format
->id
)
3751 case WINED3DFMT_B8G8R8_UNORM
:
3752 TRACE("[FAILED] - Not enumerated on Windows.\n");
3754 case WINED3DFMT_B8G8R8A8_UNORM
:
3755 case WINED3DFMT_B8G8R8X8_UNORM
:
3756 case WINED3DFMT_B5G6R5_UNORM
:
3757 case WINED3DFMT_B5G5R5X1_UNORM
:
3758 case WINED3DFMT_B5G5R5A1_UNORM
:
3759 case WINED3DFMT_B4G4R4A4_UNORM
:
3760 case WINED3DFMT_B2G3R3_UNORM
:
3761 case WINED3DFMT_A8_UNORM
:
3762 case WINED3DFMT_B2G3R3A8_UNORM
:
3763 case WINED3DFMT_B4G4R4X4_UNORM
:
3764 case WINED3DFMT_R10G10B10A2_UNORM
:
3765 case WINED3DFMT_R8G8B8A8_UNORM
:
3766 case WINED3DFMT_R8G8B8X8_UNORM
:
3767 case WINED3DFMT_R16G16_UNORM
:
3768 case WINED3DFMT_B10G10R10A2_UNORM
:
3769 case WINED3DFMT_R16G16B16A16_UNORM
:
3770 case WINED3DFMT_P8_UINT
:
3774 TRACE("[FAILED] - Not available on GDI surfaces.\n");
3779 /* All formats that are supported for textures are supported for surfaces
3781 if (check_format
->flags
& WINED3DFMT_FLAG_TEXTURE
)
3783 /* All depth stencil formats are supported on surfaces */
3784 if (CheckDepthStencilCapability(adapter
, adapter_format
, check_format
)) return TRUE
;
3786 /* If opengl can't process the format natively, the blitter may be able to convert it */
3787 if (adapter
->blitter
->blit_supported(&adapter
->gl_info
, WINED3D_BLIT_OP_COLOR_BLIT
,
3788 NULL
, WINED3D_POOL_DEFAULT
, 0, check_format
,
3789 NULL
, WINED3D_POOL_DEFAULT
, 0, adapter_format
))
3795 /* Reject other formats */
3796 TRACE("[FAILED]\n");
3800 /* OpenGL supports mipmapping on all formats. Wrapping is unsupported, but we
3801 * have to report mipmapping so we cannot reject WRAPANDMIP. Tests show that
3802 * Windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to
3803 * show that wrapping is supported. The lack of filtering will sort out the
3804 * mipmapping capability anyway.
3806 * For now lets report this on all formats, but in the future we may want to
3807 * restrict it to some should applications need that. */
3808 HRESULT CDECL
wined3d_check_device_format(const struct wined3d
*wined3d
, UINT adapter_idx
,
3809 enum wined3d_device_type device_type
, enum wined3d_format_id adapter_format_id
, DWORD usage
,
3810 enum wined3d_resource_type resource_type
, enum wined3d_format_id check_format_id
)
3812 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
3813 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3814 const struct wined3d_format
*adapter_format
= wined3d_get_format(gl_info
, adapter_format_id
);
3815 const struct wined3d_format
*format
= wined3d_get_format(gl_info
, check_format_id
);
3816 DWORD format_flags
= 0;
3817 DWORD allowed_usage
;
3819 TRACE("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s,\n"
3820 "resource_type %s, check_format %s.\n",
3821 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(adapter_format_id
),
3822 debug_d3dusage(usage
), debug_d3dusagequery(usage
), debug_d3dresourcetype(resource_type
),
3823 debug_d3dformat(check_format_id
));
3825 if (adapter_idx
>= wined3d
->adapter_count
)
3826 return WINED3DERR_INVALIDCALL
;
3828 switch (resource_type
)
3830 case WINED3D_RTYPE_CUBE_TEXTURE
:
3831 if (!gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3833 TRACE("[FAILED] - No cube texture support.\n");
3834 return WINED3DERR_NOTAVAILABLE
;
3837 format_flags
|= WINED3DFMT_FLAG_TEXTURE
;
3838 allowed_usage
= WINED3DUSAGE_AUTOGENMIPMAP
3839 | WINED3DUSAGE_DYNAMIC
3840 | WINED3DUSAGE_RENDERTARGET
3841 | WINED3DUSAGE_SOFTWAREPROCESSING
3842 | WINED3DUSAGE_QUERY_FILTER
3843 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
3844 | WINED3DUSAGE_QUERY_SRGBREAD
3845 | WINED3DUSAGE_QUERY_SRGBWRITE
3846 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
3847 | WINED3DUSAGE_QUERY_WRAPANDMIP
;
3850 case WINED3D_RTYPE_SURFACE
:
3851 if (!CheckSurfaceCapability(adapter
, adapter_format
, format
, wined3d
->flags
& WINED3D_NO3D
))
3853 TRACE("[FAILED] - Not supported for plain surfaces.\n");
3854 return WINED3DERR_NOTAVAILABLE
;
3857 allowed_usage
= WINED3DUSAGE_DEPTHSTENCIL
3858 | WINED3DUSAGE_RENDERTARGET
3859 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
;
3862 case WINED3D_RTYPE_TEXTURE
:
3863 if ((usage
& WINED3DUSAGE_DEPTHSTENCIL
) && (format
->flags
& WINED3DFMT_FLAG_SHADOW
)
3864 && !gl_info
->supported
[ARB_SHADOW
])
3866 TRACE("[FAILED] - No shadow sampler support.\n");
3867 return WINED3DERR_NOTAVAILABLE
;
3870 format_flags
|= WINED3DFMT_FLAG_TEXTURE
;
3871 allowed_usage
= WINED3DUSAGE_AUTOGENMIPMAP
3872 | WINED3DUSAGE_DEPTHSTENCIL
3873 | WINED3DUSAGE_DYNAMIC
3874 | WINED3DUSAGE_RENDERTARGET
3875 | WINED3DUSAGE_SOFTWAREPROCESSING
3876 | WINED3DUSAGE_QUERY_FILTER
3877 | WINED3DUSAGE_QUERY_LEGACYBUMPMAP
3878 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
3879 | WINED3DUSAGE_QUERY_SRGBREAD
3880 | WINED3DUSAGE_QUERY_SRGBWRITE
3881 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
3882 | WINED3DUSAGE_QUERY_WRAPANDMIP
;
3885 case WINED3D_RTYPE_VOLUME_TEXTURE
:
3886 case WINED3D_RTYPE_VOLUME
:
3887 /* Volume is to VolumeTexture what Surface is to Texture, but its
3888 * usage caps are not documented. Most driver seem to offer
3889 * (nearly) the same on Volume and VolumeTexture, so do that too. */
3890 if (!gl_info
->supported
[EXT_TEXTURE3D
])
3892 TRACE("[FAILED] - No volume texture support.\n");
3893 return WINED3DERR_NOTAVAILABLE
;
3896 /* The GL_EXT_texture_compression_s3tc spec requires that loading
3897 * an s3tc compressed texture results in an error. While the D3D
3898 * refrast does support s3tc volumes, at least the nvidia Windows
3899 * driver does not, so we're free not to support this format. */
3900 switch (check_format_id
)
3902 case WINED3DFMT_DXT1
:
3903 case WINED3DFMT_DXT2
:
3904 case WINED3DFMT_DXT3
:
3905 case WINED3DFMT_DXT4
:
3906 case WINED3DFMT_DXT5
:
3907 TRACE("[FAILED] - DXTn does not support 3D textures.\n");
3908 return WINED3DERR_NOTAVAILABLE
;
3911 /* Do nothing, continue with checking the format below */
3915 format_flags
|= WINED3DFMT_FLAG_TEXTURE
;
3916 allowed_usage
= WINED3DUSAGE_DYNAMIC
3917 | WINED3DUSAGE_SOFTWAREPROCESSING
3918 | WINED3DUSAGE_QUERY_FILTER
3919 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
3920 | WINED3DUSAGE_QUERY_SRGBREAD
3921 | WINED3DUSAGE_QUERY_SRGBWRITE
3922 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
3923 | WINED3DUSAGE_QUERY_WRAPANDMIP
;
3927 FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type
));
3928 return WINED3DERR_NOTAVAILABLE
;
3931 if ((usage
& allowed_usage
) != usage
)
3933 TRACE("Requested usage %#x, but resource type %s only allows %#x.\n",
3934 usage
, debug_d3dresourcetype(resource_type
), allowed_usage
);
3935 return WINED3DERR_NOTAVAILABLE
;
3938 if (usage
& WINED3DUSAGE_QUERY_FILTER
)
3939 format_flags
|= WINED3DFMT_FLAG_FILTERING
;
3940 if (usage
& WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
3941 format_flags
|= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
;
3942 if (usage
& WINED3DUSAGE_QUERY_SRGBREAD
)
3943 format_flags
|= WINED3DFMT_FLAG_SRGB_READ
;
3944 if (usage
& WINED3DUSAGE_QUERY_SRGBWRITE
)
3945 format_flags
|= WINED3DFMT_FLAG_SRGB_WRITE
;
3946 if (usage
& WINED3DUSAGE_QUERY_VERTEXTEXTURE
)
3947 format_flags
|= WINED3DFMT_FLAG_VTF
;
3948 if (usage
& WINED3DUSAGE_QUERY_LEGACYBUMPMAP
)
3949 format_flags
|= WINED3DFMT_FLAG_BUMPMAP
;
3951 if ((format
->flags
& format_flags
) != format_flags
)
3953 TRACE("Requested format flags %#x, but format %s only has %#x.\n",
3954 format_flags
, debug_d3dformat(check_format_id
), format
->flags
);
3955 return WINED3DERR_NOTAVAILABLE
;
3958 if ((format_flags
& WINED3DFMT_FLAG_TEXTURE
) && (wined3d
->flags
& WINED3D_NO3D
))
3960 TRACE("Requested texturing support, but wined3d was created with WINED3D_NO3D.\n");
3961 return WINED3DERR_NOTAVAILABLE
;
3964 if ((usage
& WINED3DUSAGE_DEPTHSTENCIL
)
3965 && !CheckDepthStencilCapability(adapter
, adapter_format
, format
))
3967 TRACE("Requested WINED3DUSAGE_DEPTHSTENCIL, but format %s is not supported for depth / stencil buffers.\n",
3968 debug_d3dformat(check_format_id
));
3969 return WINED3DERR_NOTAVAILABLE
;
3972 if ((usage
& WINED3DUSAGE_RENDERTARGET
)
3973 && !CheckRenderTargetCapability(adapter
, adapter_format
, format
))
3975 TRACE("Requested WINED3DUSAGE_RENDERTARGET, but format %s is not supported for render targets.\n",
3976 debug_d3dformat(check_format_id
));
3977 return WINED3DERR_NOTAVAILABLE
;
3980 if ((usage
& WINED3DUSAGE_AUTOGENMIPMAP
) && !gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
3982 TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n");
3983 return WINED3DOK_NOAUTOGEN
;
3989 HRESULT CDECL
wined3d_check_device_format_conversion(const struct wined3d
*wined3d
, UINT adapter_idx
,
3990 enum wined3d_device_type device_type
, enum wined3d_format_id src_format
, enum wined3d_format_id dst_format
)
3992 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
3993 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(src_format
),
3994 debug_d3dformat(dst_format
));
3999 HRESULT CDECL
wined3d_check_device_type(const struct wined3d
*wined3d
, UINT adapter_idx
,
4000 enum wined3d_device_type device_type
, enum wined3d_format_id display_format
,
4001 enum wined3d_format_id backbuffer_format
, BOOL windowed
)
4003 BOOL present_conversion
= wined3d
->flags
& WINED3D_PRESENT_CONVERSION
;
4005 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
4006 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), debug_d3dformat(display_format
),
4007 debug_d3dformat(backbuffer_format
), windowed
);
4009 if (adapter_idx
>= wined3d
->adapter_count
)
4010 return WINED3DERR_INVALIDCALL
;
4012 /* The task of this function is to check whether a certain display / backbuffer format
4013 * combination is available on the given adapter. In fullscreen mode microsoft specified
4014 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
4015 * and display format should match exactly.
4016 * In windowed mode format conversion can occur and this depends on the driver. */
4018 /* There are only 4 display formats. */
4019 if (!(display_format
== WINED3DFMT_B5G6R5_UNORM
4020 || display_format
== WINED3DFMT_B5G5R5X1_UNORM
4021 || display_format
== WINED3DFMT_B8G8R8X8_UNORM
4022 || display_format
== WINED3DFMT_B10G10R10A2_UNORM
))
4024 TRACE("Format %s is not supported as display format.\n", debug_d3dformat(display_format
));
4025 return WINED3DERR_NOTAVAILABLE
;
4030 /* If the requested display format is not available, don't continue. */
4031 if (!wined3d_get_adapter_mode_count(wined3d
, adapter_idx
,
4032 display_format
, WINED3D_SCANLINE_ORDERING_UNKNOWN
))
4034 TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format
));
4035 return WINED3DERR_NOTAVAILABLE
;
4038 present_conversion
= FALSE
;
4040 else if (display_format
== WINED3DFMT_B10G10R10A2_UNORM
)
4042 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode. */
4043 TRACE("Unsupported format combination %s / %s in windowed mode.\n",
4044 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4045 return WINED3DERR_NOTAVAILABLE
;
4048 if (present_conversion
)
4050 /* Use the display format as back buffer format if the latter is
4051 * WINED3DFMT_UNKNOWN. */
4052 if (backbuffer_format
== WINED3DFMT_UNKNOWN
)
4053 backbuffer_format
= display_format
;
4055 if (FAILED(wined3d_check_device_format_conversion(wined3d
, adapter_idx
,
4056 device_type
, backbuffer_format
, display_format
)))
4058 TRACE("Format conversion from %s to %s not supported.\n",
4059 debug_d3dformat(backbuffer_format
), debug_d3dformat(display_format
));
4060 return WINED3DERR_NOTAVAILABLE
;
4065 /* When format conversion from the back buffer format to the display
4066 * format is not allowed, only a limited number of combinations are
4069 if (display_format
== WINED3DFMT_B5G6R5_UNORM
&& backbuffer_format
!= WINED3DFMT_B5G6R5_UNORM
)
4071 TRACE("Unsupported format combination %s / %s.\n",
4072 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4073 return WINED3DERR_NOTAVAILABLE
;
4076 if (display_format
== WINED3DFMT_B5G5R5X1_UNORM
4077 && !(backbuffer_format
== WINED3DFMT_B5G5R5X1_UNORM
|| backbuffer_format
== WINED3DFMT_B5G5R5A1_UNORM
))
4079 TRACE("Unsupported format combination %s / %s.\n",
4080 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4081 return WINED3DERR_NOTAVAILABLE
;
4084 if (display_format
== WINED3DFMT_B8G8R8X8_UNORM
4085 && !(backbuffer_format
== WINED3DFMT_B8G8R8X8_UNORM
|| backbuffer_format
== WINED3DFMT_B8G8R8A8_UNORM
))
4087 TRACE("Unsupported format combination %s / %s.\n",
4088 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4089 return WINED3DERR_NOTAVAILABLE
;
4092 if (display_format
== WINED3DFMT_B10G10R10A2_UNORM
4093 && backbuffer_format
!= WINED3DFMT_B10G10R10A2_UNORM
)
4095 TRACE("Unsupported format combination %s / %s.\n",
4096 debug_d3dformat(display_format
), debug_d3dformat(backbuffer_format
));
4097 return WINED3DERR_NOTAVAILABLE
;
4101 /* Validate that the back buffer format is usable for render targets. */
4102 if (FAILED(wined3d_check_device_format(wined3d
, adapter_idx
, device_type
, display_format
,
4103 WINED3DUSAGE_RENDERTARGET
, WINED3D_RTYPE_SURFACE
, backbuffer_format
)))
4105 TRACE("Format %s not allowed for render targets.\n", debug_d3dformat(backbuffer_format
));
4106 return WINED3DERR_NOTAVAILABLE
;
4112 HRESULT CDECL
wined3d_get_device_caps(const struct wined3d
*wined3d
, UINT adapter_idx
,
4113 enum wined3d_device_type device_type
, WINED3DCAPS
*caps
)
4115 const struct wined3d_adapter
*adapter
= &wined3d
->adapters
[adapter_idx
];
4116 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
4117 struct shader_caps shader_caps
;
4118 struct fragment_caps fragment_caps
;
4119 struct wined3d_vertex_caps vertex_caps
;
4120 DWORD ckey_caps
, blit_caps
, fx_caps
;
4122 TRACE("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
4123 wined3d
, adapter_idx
, debug_d3ddevicetype(device_type
), caps
);
4125 if (adapter_idx
>= wined3d
->adapter_count
)
4126 return WINED3DERR_INVALIDCALL
;
4128 caps
->DeviceType
= (device_type
== WINED3D_DEVICE_TYPE_HAL
) ? WINED3D_DEVICE_TYPE_HAL
: WINED3D_DEVICE_TYPE_REF
;
4129 caps
->AdapterOrdinal
= adapter_idx
;
4132 caps
->Caps2
= WINED3DCAPS2_CANRENDERWINDOWED
|
4133 WINED3DCAPS2_FULLSCREENGAMMA
|
4134 WINED3DCAPS2_DYNAMICTEXTURES
;
4135 if (gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
4136 caps
->Caps2
|= WINED3DCAPS2_CANAUTOGENMIPMAP
;
4138 caps
->Caps3
= WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
4139 WINED3DCAPS3_COPY_TO_VIDMEM
|
4140 WINED3DCAPS3_COPY_TO_SYSTEMMEM
;
4142 caps
->PresentationIntervals
= WINED3DPRESENT_INTERVAL_IMMEDIATE
|
4143 WINED3DPRESENT_INTERVAL_ONE
;
4145 caps
->CursorCaps
= WINED3DCURSORCAPS_COLOR
|
4146 WINED3DCURSORCAPS_LOWRES
;
4148 caps
->DevCaps
= WINED3DDEVCAPS_FLOATTLVERTEX
|
4149 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY
|
4150 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
4151 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY
|
4152 WINED3DDEVCAPS_DRAWPRIMTLVERTEX
|
4153 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT
|
4154 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY
|
4155 WINED3DDEVCAPS_PUREDEVICE
|
4156 WINED3DDEVCAPS_HWRASTERIZATION
|
4157 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY
|
4158 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY
|
4159 WINED3DDEVCAPS_CANRENDERAFTERFLIP
|
4160 WINED3DDEVCAPS_DRAWPRIMITIVES2
|
4161 WINED3DDEVCAPS_DRAWPRIMITIVES2EX
;
4163 caps
->PrimitiveMiscCaps
= WINED3DPMISCCAPS_CULLNONE
|
4164 WINED3DPMISCCAPS_CULLCCW
|
4165 WINED3DPMISCCAPS_CULLCW
|
4166 WINED3DPMISCCAPS_COLORWRITEENABLE
|
4167 WINED3DPMISCCAPS_CLIPTLVERTS
|
4168 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
4169 WINED3DPMISCCAPS_MASKZ
|
4170 WINED3DPMISCCAPS_BLENDOP
|
4171 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
;
4173 WINED3DPMISCCAPS_NULLREFERENCE
4174 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
4175 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
4176 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
4178 if (gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
] && gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
4179 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_SEPARATEALPHABLEND
;
4180 if (gl_info
->supported
[EXT_DRAW_BUFFERS2
])
4181 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS
;
4182 if (gl_info
->supported
[ARB_FRAMEBUFFER_SRGB
])
4183 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_POSTBLENDSRGBCONVERT
;
4185 caps
->RasterCaps
= WINED3DPRASTERCAPS_DITHER
|
4186 WINED3DPRASTERCAPS_PAT
|
4187 WINED3DPRASTERCAPS_WFOG
|
4188 WINED3DPRASTERCAPS_ZFOG
|
4189 WINED3DPRASTERCAPS_FOGVERTEX
|
4190 WINED3DPRASTERCAPS_FOGTABLE
|
4191 WINED3DPRASTERCAPS_STIPPLE
|
4192 WINED3DPRASTERCAPS_SUBPIXEL
|
4193 WINED3DPRASTERCAPS_ZTEST
|
4194 WINED3DPRASTERCAPS_SCISSORTEST
|
4195 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
4196 WINED3DPRASTERCAPS_DEPTHBIAS
;
4198 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4200 caps
->RasterCaps
|= WINED3DPRASTERCAPS_ANISOTROPY
|
4201 WINED3DPRASTERCAPS_ZBIAS
|
4202 WINED3DPRASTERCAPS_MIPMAPLODBIAS
;
4205 caps
->ZCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4206 WINED3DPCMPCAPS_EQUAL
|
4207 WINED3DPCMPCAPS_GREATER
|
4208 WINED3DPCMPCAPS_GREATEREQUAL
|
4209 WINED3DPCMPCAPS_LESS
|
4210 WINED3DPCMPCAPS_LESSEQUAL
|
4211 WINED3DPCMPCAPS_NEVER
|
4212 WINED3DPCMPCAPS_NOTEQUAL
;
4214 caps
->SrcBlendCaps
= WINED3DPBLENDCAPS_BOTHINVSRCALPHA
|
4215 WINED3DPBLENDCAPS_BOTHSRCALPHA
|
4216 WINED3DPBLENDCAPS_DESTALPHA
|
4217 WINED3DPBLENDCAPS_DESTCOLOR
|
4218 WINED3DPBLENDCAPS_INVDESTALPHA
|
4219 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4220 WINED3DPBLENDCAPS_INVSRCALPHA
|
4221 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4222 WINED3DPBLENDCAPS_ONE
|
4223 WINED3DPBLENDCAPS_SRCALPHA
|
4224 WINED3DPBLENDCAPS_SRCALPHASAT
|
4225 WINED3DPBLENDCAPS_SRCCOLOR
|
4226 WINED3DPBLENDCAPS_ZERO
;
4228 caps
->DestBlendCaps
= WINED3DPBLENDCAPS_DESTALPHA
|
4229 WINED3DPBLENDCAPS_DESTCOLOR
|
4230 WINED3DPBLENDCAPS_INVDESTALPHA
|
4231 WINED3DPBLENDCAPS_INVDESTCOLOR
|
4232 WINED3DPBLENDCAPS_INVSRCALPHA
|
4233 WINED3DPBLENDCAPS_INVSRCCOLOR
|
4234 WINED3DPBLENDCAPS_ONE
|
4235 WINED3DPBLENDCAPS_SRCALPHA
|
4236 WINED3DPBLENDCAPS_SRCCOLOR
|
4237 WINED3DPBLENDCAPS_ZERO
;
4238 /* NOTE: WINED3DPBLENDCAPS_SRCALPHASAT is not supported as dest blend factor,
4239 * according to the glBlendFunc manpage
4241 * WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA are
4242 * legacy settings for srcblend only
4245 if (gl_info
->supported
[EXT_BLEND_COLOR
])
4247 caps
->SrcBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4248 caps
->DestBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4252 caps
->AlphaCmpCaps
= WINED3DPCMPCAPS_ALWAYS
|
4253 WINED3DPCMPCAPS_EQUAL
|
4254 WINED3DPCMPCAPS_GREATER
|
4255 WINED3DPCMPCAPS_GREATEREQUAL
|
4256 WINED3DPCMPCAPS_LESS
|
4257 WINED3DPCMPCAPS_LESSEQUAL
|
4258 WINED3DPCMPCAPS_NEVER
|
4259 WINED3DPCMPCAPS_NOTEQUAL
;
4261 caps
->ShadeCaps
= WINED3DPSHADECAPS_SPECULARGOURAUDRGB
|
4262 WINED3DPSHADECAPS_COLORGOURAUDRGB
|
4263 WINED3DPSHADECAPS_ALPHAFLATBLEND
|
4264 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND
|
4265 WINED3DPSHADECAPS_COLORFLATRGB
|
4266 WINED3DPSHADECAPS_FOGFLAT
|
4267 WINED3DPSHADECAPS_FOGGOURAUD
|
4268 WINED3DPSHADECAPS_SPECULARFLATRGB
;
4270 caps
->TextureCaps
= WINED3DPTEXTURECAPS_ALPHA
|
4271 WINED3DPTEXTURECAPS_ALPHAPALETTE
|
4272 WINED3DPTEXTURECAPS_TRANSPARENCY
|
4273 WINED3DPTEXTURECAPS_BORDER
|
4274 WINED3DPTEXTURECAPS_MIPMAP
|
4275 WINED3DPTEXTURECAPS_PROJECTED
|
4276 WINED3DPTEXTURECAPS_PERSPECTIVE
;
4278 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4280 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_POW2
|
4281 WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL
;
4284 if (gl_info
->supported
[EXT_TEXTURE3D
])
4286 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP
|
4287 WINED3DPTEXTURECAPS_MIPVOLUMEMAP
;
4288 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4290 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2
;
4294 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4296 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP
|
4297 WINED3DPTEXTURECAPS_MIPCUBEMAP
;
4298 if (!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
4300 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP_POW2
;
4304 caps
->TextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4305 WINED3DPTFILTERCAPS_MAGFPOINT
|
4306 WINED3DPTFILTERCAPS_MINFLINEAR
|
4307 WINED3DPTFILTERCAPS_MINFPOINT
|
4308 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4309 WINED3DPTFILTERCAPS_MIPFPOINT
|
4310 WINED3DPTFILTERCAPS_LINEAR
|
4311 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4312 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4313 WINED3DPTFILTERCAPS_MIPLINEAR
|
4314 WINED3DPTFILTERCAPS_MIPNEAREST
|
4315 WINED3DPTFILTERCAPS_NEAREST
;
4317 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4319 caps
->TextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4320 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4323 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4325 caps
->CubeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4326 WINED3DPTFILTERCAPS_MAGFPOINT
|
4327 WINED3DPTFILTERCAPS_MINFLINEAR
|
4328 WINED3DPTFILTERCAPS_MINFPOINT
|
4329 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4330 WINED3DPTFILTERCAPS_MIPFPOINT
|
4331 WINED3DPTFILTERCAPS_LINEAR
|
4332 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4333 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4334 WINED3DPTFILTERCAPS_MIPLINEAR
|
4335 WINED3DPTFILTERCAPS_MIPNEAREST
|
4336 WINED3DPTFILTERCAPS_NEAREST
;
4338 if (gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
])
4340 caps
->CubeTextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
|
4341 WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4346 caps
->CubeTextureFilterCaps
= 0;
4349 if (gl_info
->supported
[EXT_TEXTURE3D
])
4351 caps
->VolumeTextureFilterCaps
= WINED3DPTFILTERCAPS_MAGFLINEAR
|
4352 WINED3DPTFILTERCAPS_MAGFPOINT
|
4353 WINED3DPTFILTERCAPS_MINFLINEAR
|
4354 WINED3DPTFILTERCAPS_MINFPOINT
|
4355 WINED3DPTFILTERCAPS_MIPFLINEAR
|
4356 WINED3DPTFILTERCAPS_MIPFPOINT
|
4357 WINED3DPTFILTERCAPS_LINEAR
|
4358 WINED3DPTFILTERCAPS_LINEARMIPLINEAR
|
4359 WINED3DPTFILTERCAPS_LINEARMIPNEAREST
|
4360 WINED3DPTFILTERCAPS_MIPLINEAR
|
4361 WINED3DPTFILTERCAPS_MIPNEAREST
|
4362 WINED3DPTFILTERCAPS_NEAREST
;
4366 caps
->VolumeTextureFilterCaps
= 0;
4369 caps
->TextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4370 WINED3DPTADDRESSCAPS_CLAMP
|
4371 WINED3DPTADDRESSCAPS_WRAP
;
4373 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4375 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4377 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4379 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4381 if (gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
])
4383 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4386 if (gl_info
->supported
[EXT_TEXTURE3D
])
4388 caps
->VolumeTextureAddressCaps
= WINED3DPTADDRESSCAPS_INDEPENDENTUV
|
4389 WINED3DPTADDRESSCAPS_CLAMP
|
4390 WINED3DPTADDRESSCAPS_WRAP
;
4391 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4393 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4395 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4397 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4399 if (gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
])
4401 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4406 caps
->VolumeTextureAddressCaps
= 0;
4409 caps
->LineCaps
= WINED3DLINECAPS_TEXTURE
|
4410 WINED3DLINECAPS_ZTEST
|
4411 WINED3DLINECAPS_BLEND
|
4412 WINED3DLINECAPS_ALPHACMP
|
4413 WINED3DLINECAPS_FOG
;
4414 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
4415 * idea how generating the smoothing alpha values works; the result is different
4418 caps
->MaxTextureWidth
= gl_info
->limits
.texture_size
;
4419 caps
->MaxTextureHeight
= gl_info
->limits
.texture_size
;
4421 if (gl_info
->supported
[EXT_TEXTURE3D
])
4422 caps
->MaxVolumeExtent
= gl_info
->limits
.texture3d_size
;
4424 caps
->MaxVolumeExtent
= 0;
4426 caps
->MaxTextureRepeat
= 32768;
4427 caps
->MaxTextureAspectRatio
= gl_info
->limits
.texture_size
;
4428 caps
->MaxVertexW
= 1.0f
;
4430 caps
->GuardBandLeft
= 0.0f
;
4431 caps
->GuardBandTop
= 0.0f
;
4432 caps
->GuardBandRight
= 0.0f
;
4433 caps
->GuardBandBottom
= 0.0f
;
4435 caps
->ExtentsAdjust
= 0.0f
;
4437 caps
->StencilCaps
= WINED3DSTENCILCAPS_DECRSAT
|
4438 WINED3DSTENCILCAPS_INCRSAT
|
4439 WINED3DSTENCILCAPS_INVERT
|
4440 WINED3DSTENCILCAPS_KEEP
|
4441 WINED3DSTENCILCAPS_REPLACE
|
4442 WINED3DSTENCILCAPS_ZERO
;
4443 if (gl_info
->supported
[EXT_STENCIL_WRAP
])
4445 caps
->StencilCaps
|= WINED3DSTENCILCAPS_DECR
|
4446 WINED3DSTENCILCAPS_INCR
;
4448 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
] || gl_info
->supported
[ATI_SEPARATE_STENCIL
])
4450 caps
->StencilCaps
|= WINED3DSTENCILCAPS_TWOSIDED
;
4453 caps
->MaxAnisotropy
= gl_info
->limits
.anisotropy
;
4454 caps
->MaxPointSize
= gl_info
->limits
.pointsize_max
;
4456 caps
->MaxPrimitiveCount
= 0xfffff; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
4457 caps
->MaxVertexIndex
= 0xfffff;
4458 caps
->MaxStreams
= MAX_STREAMS
;
4459 caps
->MaxStreamStride
= 1024;
4461 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
4462 caps
->DevCaps2
= WINED3DDEVCAPS2_STREAMOFFSET
|
4463 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
;
4464 caps
->MaxNpatchTessellationLevel
= 0;
4465 caps
->MasterAdapterOrdinal
= 0;
4466 caps
->AdapterOrdinalInGroup
= 0;
4467 caps
->NumberOfAdaptersInGroup
= 1;
4469 caps
->NumSimultaneousRTs
= gl_info
->limits
.buffers
;
4471 caps
->StretchRectFilterCaps
= WINED3DPTFILTERCAPS_MINFPOINT
|
4472 WINED3DPTFILTERCAPS_MAGFPOINT
|
4473 WINED3DPTFILTERCAPS_MINFLINEAR
|
4474 WINED3DPTFILTERCAPS_MAGFLINEAR
;
4475 caps
->VertexTextureFilterCaps
= 0;
4477 adapter
->shader_backend
->shader_get_caps(&adapter
->gl_info
, &shader_caps
);
4478 adapter
->fragment_pipe
->get_caps(&adapter
->gl_info
, &fragment_caps
);
4479 adapter
->vertex_pipe
->vp_get_caps(&adapter
->gl_info
, &vertex_caps
);
4481 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
4482 caps
->PrimitiveMiscCaps
|= fragment_caps
.PrimitiveMiscCaps
;
4484 caps
->VertexShaderVersion
= shader_caps
.vs_version
;
4485 caps
->MaxVertexShaderConst
= shader_caps
.vs_uniform_count
;
4487 caps
->PixelShaderVersion
= shader_caps
.ps_version
;
4488 caps
->PixelShader1xMaxValue
= shader_caps
.ps_1x_max_value
;
4490 caps
->TextureOpCaps
= fragment_caps
.TextureOpCaps
;
4491 caps
->MaxTextureBlendStages
= fragment_caps
.MaxTextureBlendStages
;
4492 caps
->MaxSimultaneousTextures
= fragment_caps
.MaxSimultaneousTextures
;
4494 caps
->MaxUserClipPlanes
= vertex_caps
.max_user_clip_planes
;
4495 caps
->MaxActiveLights
= vertex_caps
.max_active_lights
;
4496 caps
->MaxVertexBlendMatrices
= vertex_caps
.max_vertex_blend_matrices
;
4497 caps
->MaxVertexBlendMatrixIndex
= vertex_caps
.max_vertex_blend_matrix_index
;
4498 caps
->VertexProcessingCaps
= vertex_caps
.vertex_processing_caps
;
4499 caps
->FVFCaps
= vertex_caps
.fvf_caps
;
4500 caps
->RasterCaps
|= vertex_caps
.raster_caps
;
4502 /* The following caps are shader specific, but they are things we cannot detect, or which
4503 * are the same among all shader models. So to avoid code duplication set the shader version
4504 * specific, but otherwise constant caps here
4506 if (caps
->VertexShaderVersion
>= 3)
4508 /* Where possible set the caps based on OpenGL extensions and if they
4509 * aren't set (in case of software rendering) use the VS 3.0 from
4510 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4512 caps
->VS20Caps
.caps
= WINED3DVS20CAPS_PREDICATION
;
4513 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4514 caps
->VS20Caps
.dynamic_flow_control_depth
= WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4515 caps
->VS20Caps
.temp_count
= max(32, adapter
->gl_info
.limits
.arb_vs_temps
);
4516 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
4517 caps
->VS20Caps
.static_flow_control_depth
= WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
4519 caps
->MaxVShaderInstructionsExecuted
= 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
4520 caps
->MaxVertexShader30InstructionSlots
= max(512, adapter
->gl_info
.limits
.arb_vs_instructions
);
4522 else if (caps
->VertexShaderVersion
== 2)
4524 caps
->VS20Caps
.caps
= 0;
4525 caps
->VS20Caps
.dynamic_flow_control_depth
= WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
;
4526 caps
->VS20Caps
.temp_count
= max(12, adapter
->gl_info
.limits
.arb_vs_temps
);
4527 caps
->VS20Caps
.static_flow_control_depth
= 1;
4529 caps
->MaxVShaderInstructionsExecuted
= 65535;
4530 caps
->MaxVertexShader30InstructionSlots
= 0;
4534 caps
->VS20Caps
.caps
= 0;
4535 caps
->VS20Caps
.dynamic_flow_control_depth
= 0;
4536 caps
->VS20Caps
.temp_count
= 0;
4537 caps
->VS20Caps
.static_flow_control_depth
= 0;
4539 caps
->MaxVShaderInstructionsExecuted
= 0;
4540 caps
->MaxVertexShader30InstructionSlots
= 0;
4543 if (caps
->PixelShaderVersion
>= 3)
4545 /* Where possible set the caps based on OpenGL extensions and if they
4546 * aren't set (in case of software rendering) use the PS 3.0 from
4547 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
4550 /* Caps is more or less undocumented on MSDN but it appears to be
4551 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
4552 * cards from Windows */
4553 caps
->PS20Caps
.caps
= WINED3DPS20CAPS_ARBITRARYSWIZZLE
|
4554 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS
|
4555 WINED3DPS20CAPS_PREDICATION
|
4556 WINED3DPS20CAPS_NODEPENDENTREADLIMIT
|
4557 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
4558 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4559 caps
->PS20Caps
.dynamic_flow_control_depth
= WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
4560 caps
->PS20Caps
.temp_count
= max(32, adapter
->gl_info
.limits
.arb_ps_temps
);
4561 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
4562 caps
->PS20Caps
.static_flow_control_depth
= WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
4563 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
4564 caps
->PS20Caps
.instruction_slot_count
= WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
4566 caps
->MaxPShaderInstructionsExecuted
= 65535;
4567 caps
->MaxPixelShader30InstructionSlots
= max(WINED3DMIN30SHADERINSTRUCTIONS
,
4568 adapter
->gl_info
.limits
.arb_ps_instructions
);
4570 else if(caps
->PixelShaderVersion
== 2)
4572 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
4573 caps
->PS20Caps
.caps
= 0;
4574 caps
->PS20Caps
.dynamic_flow_control_depth
= 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
4575 caps
->PS20Caps
.temp_count
= max(12, adapter
->gl_info
.limits
.arb_ps_temps
);
4576 caps
->PS20Caps
.static_flow_control_depth
= WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH
; /* Minimum: 1 */
4577 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
4578 caps
->PS20Caps
.instruction_slot_count
= WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS
;
4580 caps
->MaxPShaderInstructionsExecuted
= 512; /* Minimum value, a GeforceFX uses 1024 */
4581 caps
->MaxPixelShader30InstructionSlots
= 0;
4585 caps
->PS20Caps
.caps
= 0;
4586 caps
->PS20Caps
.dynamic_flow_control_depth
= 0;
4587 caps
->PS20Caps
.temp_count
= 0;
4588 caps
->PS20Caps
.static_flow_control_depth
= 0;
4589 caps
->PS20Caps
.instruction_slot_count
= 0;
4591 caps
->MaxPShaderInstructionsExecuted
= 0;
4592 caps
->MaxPixelShader30InstructionSlots
= 0;
4595 if (caps
->VertexShaderVersion
>= 2)
4597 /* OpenGL supports all the formats below, perhaps not always
4598 * without conversion, but it supports them.
4599 * Further GLSL doesn't seem to have an official unsigned type so
4600 * don't advertise it yet as I'm not sure how we handle it.
4601 * We might need to add some clamping in the shader engine to
4603 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
4604 caps
->DeclTypes
= WINED3DDTCAPS_UBYTE4
|
4605 WINED3DDTCAPS_UBYTE4N
|
4606 WINED3DDTCAPS_SHORT2N
|
4607 WINED3DDTCAPS_SHORT4N
;
4608 if (gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
])
4610 caps
->DeclTypes
|= WINED3DDTCAPS_FLOAT16_2
|
4611 WINED3DDTCAPS_FLOAT16_4
;
4616 caps
->DeclTypes
= 0;
4619 /* Set DirectDraw helper Caps */
4620 ckey_caps
= WINEDDCKEYCAPS_DESTBLT
|
4621 WINEDDCKEYCAPS_SRCBLT
;
4622 fx_caps
= WINEDDFXCAPS_BLTALPHA
|
4623 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT
|
4624 WINEDDFXCAPS_BLTMIRRORUPDOWN
|
4625 WINEDDFXCAPS_BLTROTATION90
|
4626 WINEDDFXCAPS_BLTSHRINKX
|
4627 WINEDDFXCAPS_BLTSHRINKXN
|
4628 WINEDDFXCAPS_BLTSHRINKY
|
4629 WINEDDFXCAPS_BLTSHRINKXN
|
4630 WINEDDFXCAPS_BLTSTRETCHX
|
4631 WINEDDFXCAPS_BLTSTRETCHXN
|
4632 WINEDDFXCAPS_BLTSTRETCHY
|
4633 WINEDDFXCAPS_BLTSTRETCHYN
;
4634 blit_caps
= WINEDDCAPS_BLT
|
4635 WINEDDCAPS_BLTCOLORFILL
|
4636 WINEDDCAPS_BLTDEPTHFILL
|
4637 WINEDDCAPS_BLTSTRETCH
|
4638 WINEDDCAPS_CANBLTSYSMEM
|
4639 WINEDDCAPS_CANCLIP
|
4640 WINEDDCAPS_CANCLIPSTRETCHED
|
4641 WINEDDCAPS_COLORKEY
|
4642 WINEDDCAPS_COLORKEYHWASSIST
|
4643 WINEDDCAPS_ALIGNBOUNDARYSRC
;
4645 /* Fill the ddraw caps structure */
4646 caps
->ddraw_caps
.caps
= WINEDDCAPS_GDI
|
4647 WINEDDCAPS_PALETTE
|
4649 caps
->ddraw_caps
.caps2
= WINEDDCAPS2_CERTIFIED
|
4650 WINEDDCAPS2_NOPAGELOCKREQUIRED
|
4651 WINEDDCAPS2_PRIMARYGAMMA
|
4652 WINEDDCAPS2_WIDESURFACES
|
4653 WINEDDCAPS2_CANRENDERWINDOWED
;
4654 caps
->ddraw_caps
.color_key_caps
= ckey_caps
;
4655 caps
->ddraw_caps
.fx_caps
= fx_caps
;
4656 caps
->ddraw_caps
.svb_caps
= blit_caps
;
4657 caps
->ddraw_caps
.svb_color_key_caps
= ckey_caps
;
4658 caps
->ddraw_caps
.svb_fx_caps
= fx_caps
;
4659 caps
->ddraw_caps
.vsb_caps
= blit_caps
;
4660 caps
->ddraw_caps
.vsb_color_key_caps
= ckey_caps
;
4661 caps
->ddraw_caps
.vsb_fx_caps
= fx_caps
;
4662 caps
->ddraw_caps
.ssb_caps
= blit_caps
;
4663 caps
->ddraw_caps
.ssb_color_key_caps
= ckey_caps
;
4664 caps
->ddraw_caps
.ssb_fx_caps
= fx_caps
;
4666 caps
->ddraw_caps
.dds_caps
= WINEDDSCAPS_ALPHA
|
4667 WINEDDSCAPS_BACKBUFFER
|
4669 WINEDDSCAPS_FRONTBUFFER
|
4670 WINEDDSCAPS_OFFSCREENPLAIN
|
4671 WINEDDSCAPS_PALETTE
|
4672 WINEDDSCAPS_PRIMARYSURFACE
|
4673 WINEDDSCAPS_SYSTEMMEMORY
|
4674 WINEDDSCAPS_VIDEOMEMORY
|
4675 WINEDDSCAPS_VISIBLE
;
4677 if (!(wined3d
->flags
& WINED3D_NO3D
))
4679 caps
->ddraw_caps
.dds_caps
|= WINEDDSCAPS_3DDEVICE
|
4680 WINEDDSCAPS_MIPMAP
|
4681 WINEDDSCAPS_TEXTURE
|
4682 WINEDDSCAPS_ZBUFFER
;
4683 caps
->ddraw_caps
.caps
|= WINEDDCAPS_3D
;
4689 HRESULT CDECL
wined3d_device_create(struct wined3d
*wined3d
, UINT adapter_idx
, enum wined3d_device_type device_type
,
4690 HWND focus_window
, DWORD flags
, BYTE surface_alignment
, struct wined3d_device_parent
*device_parent
,
4691 struct wined3d_device
**device
)
4693 struct wined3d_device
*object
;
4696 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, device_parent %p, device %p.\n",
4697 wined3d
, adapter_idx
, device_type
, focus_window
, flags
, device_parent
, device
);
4699 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
4700 * number and create a device without a 3D adapter for 2D only operation. */
4701 if (wined3d
->adapter_count
&& adapter_idx
>= wined3d
->adapter_count
)
4702 return WINED3DERR_INVALIDCALL
;
4704 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
4706 return E_OUTOFMEMORY
;
4708 hr
= device_init(object
, wined3d
, adapter_idx
, device_type
,
4709 focus_window
, flags
, surface_alignment
, device_parent
);
4712 WARN("Failed to initialize device, hr %#x.\n", hr
);
4713 HeapFree(GetProcessHeap(), 0, object
);
4717 TRACE("Created device %p.\n", object
);
4720 device_parent
->ops
->wined3d_device_created(device_parent
, *device
);
4725 static void WINE_GLAPI
invalid_func(const void *data
)
4727 ERR("Invalid vertex attribute function called\n");
4731 static void WINE_GLAPI
invalid_texcoord_func(GLenum unit
, const void *data
)
4733 ERR("Invalid texcoord function called\n");
4737 /* Helper functions for providing vertex data to opengl. The arrays are initialized based on
4738 * the extension detection and are used in drawStridedSlow
4740 static void WINE_GLAPI
position_d3dcolor(const void *data
)
4742 DWORD pos
= *((const DWORD
*)data
);
4744 FIXME("Add a test for fixed function position from d3dcolor type\n");
4745 context_get_current()->gl_info
->gl_ops
.gl
.p_glVertex4s(D3DCOLOR_B_R(pos
),
4751 static void WINE_GLAPI
position_float4(const void *data
)
4753 const GLfloat
*pos
= data
;
4755 if (pos
[3] != 0.0f
&& pos
[3] != 1.0f
)
4757 float w
= 1.0f
/ pos
[3];
4759 context_get_current()->gl_info
->gl_ops
.gl
.p_glVertex4f(pos
[0] * w
, pos
[1] * w
, pos
[2] * w
, w
);
4763 context_get_current()->gl_info
->gl_ops
.gl
.p_glVertex3fv(pos
);
4767 static void WINE_GLAPI
diffuse_d3dcolor(const void *data
)
4769 DWORD diffuseColor
= *((const DWORD
*)data
);
4771 context_get_current()->gl_info
->gl_ops
.gl
.p_glColor4ub(D3DCOLOR_B_R(diffuseColor
),
4772 D3DCOLOR_B_G(diffuseColor
),
4773 D3DCOLOR_B_B(diffuseColor
),
4774 D3DCOLOR_B_A(diffuseColor
));
4777 static void WINE_GLAPI
specular_d3dcolor(const void *data
)
4779 DWORD specularColor
= *((const DWORD
*)data
);
4782 D3DCOLOR_B_R(specularColor
),
4783 D3DCOLOR_B_G(specularColor
),
4784 D3DCOLOR_B_B(specularColor
)
4787 context_get_current()->gl_info
->gl_ops
.ext
.p_glSecondaryColor3ubvEXT(d
);
4790 static void WINE_GLAPI
warn_no_specular_func(const void *data
)
4792 WARN("GL_EXT_secondary_color not supported\n");
4795 static void wined3d_adapter_init_ffp_attrib_ops(struct wined3d_adapter
*adapter
)
4797 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
4798 struct wined3d_d3d_info
*d3d_info
= &adapter
->d3d_info
;
4799 struct wined3d_ffp_attrib_ops
*ops
= &d3d_info
->ffp_attrib_ops
;
4801 ops
->position
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
4802 ops
->position
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
4803 ops
->position
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glVertex3fv
;
4804 if (!d3d_info
->xyzrhw
)
4805 ops
->position
[WINED3D_FFP_EMIT_FLOAT4
] = position_float4
;
4807 ops
->position
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glVertex4fv
;
4808 ops
->position
[WINED3D_FFP_EMIT_D3DCOLOR
] = position_d3dcolor
;
4809 ops
->position
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
4810 ops
->position
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
4811 ops
->position
[WINED3D_FFP_EMIT_SHORT4
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glVertex2sv
;
4812 ops
->position
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
4813 ops
->position
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
4814 ops
->position
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
4815 ops
->position
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
4816 ops
->position
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
4817 ops
->position
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
4818 ops
->position
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
4819 ops
->position
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
4820 ops
->position
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
4821 ops
->position
[WINED3D_FFP_EMIT_INVALID
] = invalid_func
;
4823 ops
->diffuse
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
4824 ops
->diffuse
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
4825 ops
->diffuse
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor3fv
;
4826 ops
->diffuse
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor4fv
;
4827 ops
->diffuse
[WINED3D_FFP_EMIT_D3DCOLOR
] = diffuse_d3dcolor
;
4828 ops
->diffuse
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
4829 ops
->diffuse
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
4830 ops
->diffuse
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
4831 ops
->diffuse
[WINED3D_FFP_EMIT_UBYTE4N
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor4ubv
;
4832 ops
->diffuse
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
4833 ops
->diffuse
[WINED3D_FFP_EMIT_SHORT4N
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor4sv
;
4834 ops
->diffuse
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
4835 ops
->diffuse
[WINED3D_FFP_EMIT_USHORT4N
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor4usv
;
4836 ops
->diffuse
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
4837 ops
->diffuse
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
4838 ops
->diffuse
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
4839 ops
->diffuse
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
4840 ops
->diffuse
[WINED3D_FFP_EMIT_INVALID
] = invalid_func
;
4842 /* No 4 component entry points here. */
4843 ops
->specular
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
4844 ops
->specular
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
4845 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4846 ops
->specular
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_attrib_func
)GL_EXTCALL(glSecondaryColor3fvEXT
);
4848 ops
->specular
[WINED3D_FFP_EMIT_FLOAT3
] = warn_no_specular_func
;
4849 ops
->specular
[WINED3D_FFP_EMIT_FLOAT4
] = invalid_func
;
4850 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4851 ops
->specular
[WINED3D_FFP_EMIT_D3DCOLOR
] = specular_d3dcolor
;
4853 ops
->specular
[WINED3D_FFP_EMIT_D3DCOLOR
] = warn_no_specular_func
;
4854 ops
->specular
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
4855 ops
->specular
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
4856 ops
->specular
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
4857 ops
->specular
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
4858 ops
->specular
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
4859 ops
->specular
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
4860 ops
->specular
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
4861 ops
->specular
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
4862 ops
->specular
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
4863 ops
->specular
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
4864 ops
->specular
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
4865 ops
->specular
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
4866 ops
->specular
[WINED3D_FFP_EMIT_INVALID
] = invalid_func
;
4868 /* Only 3 component entry points here. Test how others behave. Float4
4869 * normals are used by one of our tests, trying to pass it to the pixel
4870 * shader, which fails on Windows. */
4871 ops
->normal
[WINED3D_FFP_EMIT_FLOAT1
] = invalid_func
;
4872 ops
->normal
[WINED3D_FFP_EMIT_FLOAT2
] = invalid_func
;
4873 ops
->normal
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glNormal3fv
;
4874 /* Just ignore the 4th value. */
4875 ops
->normal
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glNormal3fv
;
4876 ops
->normal
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_func
;
4877 ops
->normal
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_func
;
4878 ops
->normal
[WINED3D_FFP_EMIT_SHORT2
] = invalid_func
;
4879 ops
->normal
[WINED3D_FFP_EMIT_SHORT4
] = invalid_func
;
4880 ops
->normal
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_func
;
4881 ops
->normal
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_func
;
4882 ops
->normal
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_func
;
4883 ops
->normal
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_func
;
4884 ops
->normal
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_func
;
4885 ops
->normal
[WINED3D_FFP_EMIT_UDEC3
] = invalid_func
;
4886 ops
->normal
[WINED3D_FFP_EMIT_DEC3N
] = invalid_func
;
4887 ops
->normal
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_func
;
4888 ops
->normal
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_func
;
4889 ops
->normal
[WINED3D_FFP_EMIT_INVALID
] = invalid_func
;
4891 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT1
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord1fvARB
;
4892 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT2
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord2fvARB
;
4893 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord3fvARB
;
4894 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord4fvARB
;
4895 ops
->texcoord
[WINED3D_FFP_EMIT_D3DCOLOR
] = invalid_texcoord_func
;
4896 ops
->texcoord
[WINED3D_FFP_EMIT_UBYTE4
] = invalid_texcoord_func
;
4897 ops
->texcoord
[WINED3D_FFP_EMIT_SHORT2
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord2svARB
;
4898 ops
->texcoord
[WINED3D_FFP_EMIT_SHORT4
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord4svARB
;
4899 ops
->texcoord
[WINED3D_FFP_EMIT_UBYTE4N
] = invalid_texcoord_func
;
4900 ops
->texcoord
[WINED3D_FFP_EMIT_SHORT2N
] = invalid_texcoord_func
;
4901 ops
->texcoord
[WINED3D_FFP_EMIT_SHORT4N
] = invalid_texcoord_func
;
4902 ops
->texcoord
[WINED3D_FFP_EMIT_USHORT2N
] = invalid_texcoord_func
;
4903 ops
->texcoord
[WINED3D_FFP_EMIT_USHORT4N
] = invalid_texcoord_func
;
4904 ops
->texcoord
[WINED3D_FFP_EMIT_UDEC3
] = invalid_texcoord_func
;
4905 ops
->texcoord
[WINED3D_FFP_EMIT_DEC3N
] = invalid_texcoord_func
;
4906 if (gl_info
->supported
[NV_HALF_FLOAT
])
4908 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT. */
4909 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT16_2
] =
4910 (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord2hvNV
;
4911 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT16_4
] =
4912 (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord4hvNV
;
4916 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT16_2
] = invalid_texcoord_func
;
4917 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT16_4
] = invalid_texcoord_func
;
4919 ops
->texcoord
[WINED3D_FFP_EMIT_INVALID
] = invalid_texcoord_func
;
4922 static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter
*adapter
, HDC dc
)
4924 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
4927 if (gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
])
4929 UINT attrib_count
= 0;
4935 attribute
= WGL_NUMBER_PIXEL_FORMATS_ARB
;
4936 GL_EXTCALL(wglGetPixelFormatAttribivARB(dc
, 0, 0, 1, &attribute
, &cfg_count
));
4938 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, cfg_count
* sizeof(*adapter
->cfgs
));
4939 attribs
[attrib_count
++] = WGL_RED_BITS_ARB
;
4940 attribs
[attrib_count
++] = WGL_GREEN_BITS_ARB
;
4941 attribs
[attrib_count
++] = WGL_BLUE_BITS_ARB
;
4942 attribs
[attrib_count
++] = WGL_ALPHA_BITS_ARB
;
4943 attribs
[attrib_count
++] = WGL_COLOR_BITS_ARB
;
4944 attribs
[attrib_count
++] = WGL_DEPTH_BITS_ARB
;
4945 attribs
[attrib_count
++] = WGL_STENCIL_BITS_ARB
;
4946 attribs
[attrib_count
++] = WGL_DRAW_TO_WINDOW_ARB
;
4947 attribs
[attrib_count
++] = WGL_PIXEL_TYPE_ARB
;
4948 attribs
[attrib_count
++] = WGL_DOUBLE_BUFFER_ARB
;
4949 attribs
[attrib_count
++] = WGL_AUX_BUFFERS_ARB
;
4951 for (i
= 0, adapter
->cfg_count
= 0; i
< cfg_count
; ++i
)
4953 struct wined3d_pixel_format
*cfg
= &adapter
->cfgs
[adapter
->cfg_count
];
4954 int format_id
= i
+ 1;
4956 if (!GL_EXTCALL(wglGetPixelFormatAttribivARB(dc
, format_id
, 0, attrib_count
, attribs
, values
)))
4959 cfg
->iPixelFormat
= format_id
;
4960 cfg
->redSize
= values
[0];
4961 cfg
->greenSize
= values
[1];
4962 cfg
->blueSize
= values
[2];
4963 cfg
->alphaSize
= values
[3];
4964 cfg
->colorSize
= values
[4];
4965 cfg
->depthSize
= values
[5];
4966 cfg
->stencilSize
= values
[6];
4967 cfg
->windowDrawable
= values
[7];
4968 cfg
->iPixelType
= values
[8];
4969 cfg
->doubleBuffer
= values
[9];
4970 cfg
->auxBuffers
= values
[10];
4972 cfg
->numSamples
= 0;
4973 /* Check multisample support. */
4974 if (gl_info
->supported
[ARB_MULTISAMPLE
])
4976 int attribs
[2] = {WGL_SAMPLE_BUFFERS_ARB
, WGL_SAMPLES_ARB
};
4979 if (GL_EXTCALL(wglGetPixelFormatAttribivARB(dc
, format_id
, 0, 2, attribs
, values
)))
4981 /* values[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether
4982 * multisampling is supported. values[1] = number of
4983 * multisample buffers. */
4985 cfg
->numSamples
= values
[1];
4989 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
4990 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
4991 cfg
->iPixelFormat
, cfg
->iPixelType
, cfg
->doubleBuffer
,
4992 cfg
->redSize
, cfg
->greenSize
, cfg
->blueSize
, cfg
->alphaSize
,
4993 cfg
->depthSize
, cfg
->stencilSize
, cfg
->numSamples
, cfg
->windowDrawable
);
4995 ++adapter
->cfg_count
;
5002 cfg_count
= DescribePixelFormat(dc
, 0, 0, 0);
5003 adapter
->cfgs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, cfg_count
* sizeof(*adapter
->cfgs
));
5005 for (i
= 0, adapter
->cfg_count
= 0; i
< cfg_count
; ++i
)
5007 struct wined3d_pixel_format
*cfg
= &adapter
->cfgs
[adapter
->cfg_count
];
5008 PIXELFORMATDESCRIPTOR pfd
;
5009 int format_id
= i
+ 1;
5011 if (!DescribePixelFormat(dc
, format_id
, sizeof(pfd
), &pfd
))
5014 /* We only want HW acceleration using an OpenGL ICD driver.
5015 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering.
5016 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD
5017 * driver (e.g. 3dfx minigl). */
5018 if (pfd
.dwFlags
& (PFD_GENERIC_FORMAT
| PFD_GENERIC_ACCELERATED
))
5020 TRACE("Skipping format %d because it isn't ICD accelerated.\n", format_id
);
5024 cfg
->iPixelFormat
= format_id
;
5025 cfg
->redSize
= pfd
.cRedBits
;
5026 cfg
->greenSize
= pfd
.cGreenBits
;
5027 cfg
->blueSize
= pfd
.cBlueBits
;
5028 cfg
->alphaSize
= pfd
.cAlphaBits
;
5029 cfg
->colorSize
= pfd
.cColorBits
;
5030 cfg
->depthSize
= pfd
.cDepthBits
;
5031 cfg
->stencilSize
= pfd
.cStencilBits
;
5032 cfg
->windowDrawable
= (pfd
.dwFlags
& PFD_DRAW_TO_WINDOW
) ? 1 : 0;
5033 cfg
->iPixelType
= (pfd
.iPixelType
== PFD_TYPE_RGBA
) ? WGL_TYPE_RGBA_ARB
: WGL_TYPE_COLORINDEX_ARB
;
5034 cfg
->doubleBuffer
= (pfd
.dwFlags
& PFD_DOUBLEBUFFER
) ? 1 : 0;
5035 cfg
->auxBuffers
= pfd
.cAuxBuffers
;
5036 cfg
->numSamples
= 0;
5038 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5039 "depth=%d, stencil=%d, windowDrawable=%d\n",
5040 cfg
->iPixelFormat
, cfg
->iPixelType
, cfg
->doubleBuffer
,
5041 cfg
->redSize
, cfg
->greenSize
, cfg
->blueSize
, cfg
->alphaSize
,
5042 cfg
->depthSize
, cfg
->stencilSize
, cfg
->windowDrawable
);
5044 ++adapter
->cfg_count
;
5049 static BOOL
wined3d_adapter_init(struct wined3d_adapter
*adapter
, UINT ordinal
)
5051 struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
5052 struct wined3d_caps_gl_ctx caps_gl_ctx
= {0};
5053 unsigned int ctx_attrib_idx
= 0;
5054 DISPLAY_DEVICEW display_device
;
5055 GLint ctx_attribs
[3];
5057 TRACE("adapter %p, ordinal %u.\n", adapter
, ordinal
);
5059 adapter
->ordinal
= ordinal
;
5060 adapter
->monitorPoint
.x
= -1;
5061 adapter
->monitorPoint
.y
= -1;
5063 /* Dynamically load all GL core functions */
5064 #ifdef USE_WIN32_OPENGL
5066 HMODULE mod_gl
= GetModuleHandleA("opengl32.dll");
5067 #define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
5070 gl_info
->gl_ops
.wgl
.p_wglSwapBuffers
= (void *)GetProcAddress(mod_gl
, "wglSwapBuffers");
5073 /* To bypass the opengl32 thunks retrieve functions from the WGL driver instead of opengl32 */
5075 HDC hdc
= GetDC( 0 );
5076 const struct opengl_funcs
*wgl_driver
= __wine_get_wgl_driver( hdc
, WINE_WGL_DRIVER_VERSION
);
5077 ReleaseDC( 0, hdc
);
5078 if (!wgl_driver
|| wgl_driver
== (void *)-1) return FALSE
;
5079 gl_info
->gl_ops
.wgl
= wgl_driver
->wgl
;
5080 gl_info
->gl_ops
.gl
= wgl_driver
->gl
;
5084 glEnableWINE
= gl_info
->gl_ops
.gl
.p_glEnable
;
5085 glDisableWINE
= gl_info
->gl_ops
.gl
.p_glDisable
;
5087 if (!AllocateLocallyUniqueId(&adapter
->luid
))
5089 ERR("Failed to set adapter LUID (%#x).\n", GetLastError());
5092 TRACE("Allocated LUID %08x:%08x for adapter %p.\n",
5093 adapter
->luid
.HighPart
, adapter
->luid
.LowPart
, adapter
);
5095 if (!wined3d_caps_gl_ctx_create(&caps_gl_ctx
))
5097 ERR("Failed to get a GL context for adapter %p.\n", adapter
);
5101 if (context_debug_output_enabled(gl_info
))
5103 ctx_attribs
[ctx_attrib_idx
++] = WGL_CONTEXT_FLAGS_ARB
;
5104 ctx_attribs
[ctx_attrib_idx
++] = WGL_CONTEXT_DEBUG_BIT_ARB
;
5106 ctx_attribs
[ctx_attrib_idx
] = 0;
5107 wined3d_caps_gl_ctx_create_attribs(&caps_gl_ctx
, gl_info
, ctx_attribs
);
5109 if (!wined3d_adapter_init_gl_caps(adapter
))
5111 ERR("Failed to initialize GL caps for adapter %p.\n", adapter
);
5112 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5116 wined3d_adapter_init_fb_cfgs(adapter
, caps_gl_ctx
.dc
);
5117 /* We haven't found any suitable formats. This should only happen in
5118 * case of GDI software rendering, which is pretty useless anyway. */
5119 if (!adapter
->cfg_count
)
5121 WARN("No suitable pixel formats found.\n");
5122 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5123 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
5127 if (!wined3d_adapter_init_format_info(adapter
))
5129 ERR("Failed to initialize GL format info.\n");
5130 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5131 HeapFree(GetProcessHeap(), 0, adapter
->cfgs
);
5135 adapter
->TextureRam
= adapter
->driver_info
.vidmem
;
5136 adapter
->UsedTextureRam
= 0;
5137 TRACE("Emulating %u MB of texture ram.\n", adapter
->TextureRam
/ (1024 * 1024));
5139 display_device
.cb
= sizeof(display_device
);
5140 EnumDisplayDevicesW(NULL
, ordinal
, &display_device
, 0);
5141 TRACE("DeviceName: %s\n", debugstr_w(display_device
.DeviceName
));
5142 strcpyW(adapter
->DeviceName
, display_device
.DeviceName
);
5144 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5146 wined3d_adapter_init_ffp_attrib_ops(adapter
);
5151 static void wined3d_adapter_init_nogl(struct wined3d_adapter
*adapter
, UINT ordinal
)
5153 DISPLAY_DEVICEW display_device
;
5155 memset(adapter
, 0, sizeof(*adapter
));
5156 adapter
->ordinal
= ordinal
;
5157 adapter
->monitorPoint
.x
= -1;
5158 adapter
->monitorPoint
.y
= -1;
5160 adapter
->driver_info
.name
= "Display";
5161 adapter
->driver_info
.description
= "WineD3D DirectDraw Emulation";
5162 if (wined3d_settings
.emulated_textureram
)
5163 adapter
->TextureRam
= wined3d_settings
.emulated_textureram
;
5165 adapter
->TextureRam
= 128 * 1024 * 1024;
5167 initPixelFormatsNoGL(&adapter
->gl_info
);
5169 adapter
->vertex_pipe
= &none_vertex_pipe
;
5170 adapter
->fragment_pipe
= &none_fragment_pipe
;
5171 adapter
->shader_backend
= &none_shader_backend
;
5172 adapter
->blitter
= &cpu_blit
;
5174 display_device
.cb
= sizeof(display_device
);
5175 EnumDisplayDevicesW(NULL
, ordinal
, &display_device
, 0);
5176 TRACE("DeviceName: %s\n", debugstr_w(display_device
.DeviceName
));
5177 strcpyW(adapter
->DeviceName
, display_device
.DeviceName
);
5180 static void STDMETHODCALLTYPE
wined3d_null_wined3d_object_destroyed(void *parent
) {}
5182 const struct wined3d_parent_ops wined3d_null_parent_ops
=
5184 wined3d_null_wined3d_object_destroyed
,
5187 HRESULT
wined3d_init(struct wined3d
*wined3d
, UINT version
, DWORD flags
)
5189 wined3d
->dxVersion
= version
;
5191 wined3d
->flags
= flags
;
5193 TRACE("Initializing adapters.\n");
5195 if (flags
& WINED3D_NO3D
)
5197 wined3d_adapter_init_nogl(&wined3d
->adapters
[0], 0);
5198 wined3d
->adapter_count
= 1;
5202 if (!wined3d_adapter_init(&wined3d
->adapters
[0], 0))
5204 WARN("Failed to initialize adapter.\n");
5207 wined3d
->adapter_count
= 1;