1 | /*
|
---|
2 | * Copyright 2002-2004 Jason Edmeades
|
---|
3 | * Copyright 2003-2004 Raphael Junqueira
|
---|
4 | * Copyright 2004 Christian Costa
|
---|
5 | * Copyright 2005 Oliver Stieber
|
---|
6 | * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
|
---|
7 | * Copyright 2009-2011 Henri Verbeet for CodeWeavers
|
---|
8 | *
|
---|
9 | * This library is free software; you can redistribute it and/or
|
---|
10 | * modify it under the terms of the GNU Lesser General Public
|
---|
11 | * License as published by the Free Software Foundation; either
|
---|
12 | * version 2.1 of the License, or (at your option) any later version.
|
---|
13 | *
|
---|
14 | * This library is distributed in the hope that it will be useful,
|
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
17 | * Lesser General Public License for more details.
|
---|
18 | *
|
---|
19 | * You should have received a copy of the GNU Lesser General Public
|
---|
20 | * License along with this library; if not, write to the Free Software
|
---|
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
22 | */
|
---|
23 |
|
---|
24 | #include "config.h"
|
---|
25 | #include "wine/port.h"
|
---|
26 |
|
---|
27 | #include <stdio.h>
|
---|
28 |
|
---|
29 | #include "wined3d_private.h"
|
---|
30 | #include "winternl.h"
|
---|
31 | #ifdef VBOX_WITH_WDDM
|
---|
32 | #include <VBox/VBoxCrHgsmi.h>
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
---|
36 | WINE_DECLARE_DEBUG_CHANNEL(d3d_perf);
|
---|
37 |
|
---|
38 | #define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
|
---|
39 |
|
---|
40 | /* The driver names reflect the lowest GPU supported
|
---|
41 | * by a certain driver, so DRIVER_AMD_R300 supports
|
---|
42 | * R3xx, R4xx and R5xx GPUs. */
|
---|
43 | enum wined3d_display_driver
|
---|
44 | {
|
---|
45 | DRIVER_AMD_RAGE_128PRO,
|
---|
46 | DRIVER_AMD_R100,
|
---|
47 | DRIVER_AMD_R300,
|
---|
48 | DRIVER_AMD_R600,
|
---|
49 | DRIVER_INTEL_GMA800,
|
---|
50 | DRIVER_INTEL_GMA900,
|
---|
51 | DRIVER_INTEL_GMA950,
|
---|
52 | DRIVER_INTEL_GMA3000,
|
---|
53 | DRIVER_NVIDIA_TNT,
|
---|
54 | DRIVER_NVIDIA_GEFORCE2MX,
|
---|
55 | DRIVER_NVIDIA_GEFORCEFX,
|
---|
56 | DRIVER_NVIDIA_GEFORCE6,
|
---|
57 | DRIVER_UNKNOWN
|
---|
58 | };
|
---|
59 |
|
---|
60 | enum wined3d_driver_model
|
---|
61 | {
|
---|
62 | DRIVER_MODEL_WIN9X,
|
---|
63 | DRIVER_MODEL_NT40,
|
---|
64 | DRIVER_MODEL_NT5X,
|
---|
65 | DRIVER_MODEL_NT6X
|
---|
66 | };
|
---|
67 |
|
---|
68 | enum wined3d_gl_vendor
|
---|
69 | {
|
---|
70 | GL_VENDOR_UNKNOWN,
|
---|
71 | GL_VENDOR_APPLE,
|
---|
72 | GL_VENDOR_FGLRX,
|
---|
73 | GL_VENDOR_INTEL,
|
---|
74 | GL_VENDOR_MESA,
|
---|
75 | GL_VENDOR_NVIDIA,
|
---|
76 | };
|
---|
77 |
|
---|
78 | /* The d3d device ID */
|
---|
79 | static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
|
---|
80 |
|
---|
81 | /* Extension detection */
|
---|
82 | struct wined3d_extension_map
|
---|
83 | {
|
---|
84 | const char *extension_string;
|
---|
85 | enum wined3d_gl_extension extension;
|
---|
86 | };
|
---|
87 |
|
---|
88 | static const struct wined3d_extension_map gl_extension_map[] =
|
---|
89 | {
|
---|
90 | /* APPLE */
|
---|
91 | {"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE },
|
---|
92 | {"GL_APPLE_fence", APPLE_FENCE },
|
---|
93 | {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS },
|
---|
94 | {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE },
|
---|
95 | {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422 },
|
---|
96 |
|
---|
97 | /* ARB */
|
---|
98 | {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT },
|
---|
99 | {"GL_ARB_debug_output", ARB_DEBUG_OUTPUT },
|
---|
100 | {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT },
|
---|
101 | {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP },
|
---|
102 | {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE },
|
---|
103 | {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS },
|
---|
104 | {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX },
|
---|
105 | {"GL_ARB_draw_instanced", ARB_DRAW_INSTANCED },
|
---|
106 | {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM },
|
---|
107 | {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER },
|
---|
108 | {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT },
|
---|
109 | {"GL_ARB_framebuffer_sRGB", ARB_FRAMEBUFFER_SRGB },
|
---|
110 | {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4 },
|
---|
111 | {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL },
|
---|
112 | {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX },
|
---|
113 | {"GL_ARB_instanced_arrays", ARB_INSTANCED_ARRAYS, },
|
---|
114 | {"GL_ARB_internalformat_query2", ARB_INTERNALFORMAT_QUERY2, },
|
---|
115 | {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT },
|
---|
116 | {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE },
|
---|
117 | {"GL_ARB_multisample", ARB_MULTISAMPLE }, /* needs GLX_ARB_MULTISAMPLE as well */
|
---|
118 | {"GL_ARB_multitexture", ARB_MULTITEXTURE },
|
---|
119 | {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY },
|
---|
120 | {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT },
|
---|
121 | {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS },
|
---|
122 | {"GL_ARB_point_sprite", ARB_POINT_SPRITE },
|
---|
123 | {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX },
|
---|
124 | {"GL_ARB_shader_bit_encoding", ARB_SHADER_BIT_ENCODING },
|
---|
125 | {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS },
|
---|
126 | {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD },
|
---|
127 | {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100 },
|
---|
128 | {"GL_ARB_shadow", ARB_SHADOW },
|
---|
129 | {"GL_ARB_sync", ARB_SYNC },
|
---|
130 | {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP },
|
---|
131 | {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION },
|
---|
132 | {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC },
|
---|
133 | {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP },
|
---|
134 | {"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD },
|
---|
135 | {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE },
|
---|
136 | {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3 },
|
---|
137 | {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT },
|
---|
138 | {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT },
|
---|
139 | #ifdef VBOX_WITH_WINE_FIX_IBMTMR
|
---|
140 | {"GL_IBM_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT },
|
---|
141 | #endif
|
---|
142 | {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO },
|
---|
143 | {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE },
|
---|
144 | {"GL_ARB_texture_rg", ARB_TEXTURE_RG },
|
---|
145 | {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA },
|
---|
146 | {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND },
|
---|
147 | {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT },
|
---|
148 | {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM },
|
---|
149 | {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER },
|
---|
150 |
|
---|
151 | /* ATI */
|
---|
152 | {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER },
|
---|
153 | {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL },
|
---|
154 | {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC },
|
---|
155 | {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3 },
|
---|
156 | {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE },
|
---|
157 |
|
---|
158 | /* EXT */
|
---|
159 | {"GL_EXT_blend_color", EXT_BLEND_COLOR },
|
---|
160 | {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE },
|
---|
161 | {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE },
|
---|
162 | {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX },
|
---|
163 | {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT },
|
---|
164 | {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST },
|
---|
165 | {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2 },
|
---|
166 | {"GL_EXT_fog_coord", EXT_FOG_COORD },
|
---|
167 | {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT },
|
---|
168 | {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE },
|
---|
169 | {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT },
|
---|
170 | {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS },
|
---|
171 | {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4 },
|
---|
172 | {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL },
|
---|
173 | {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE },
|
---|
174 | {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS },
|
---|
175 | {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX },
|
---|
176 | {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR },
|
---|
177 | {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE },
|
---|
178 | {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP },
|
---|
179 | {"GL_EXT_texture3D", EXT_TEXTURE3D },
|
---|
180 | {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC },
|
---|
181 | {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC },
|
---|
182 | {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD },
|
---|
183 | {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE },
|
---|
184 | {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3 },
|
---|
185 | {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC},
|
---|
186 | {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS },
|
---|
187 | {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB },
|
---|
188 | {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE },
|
---|
189 | {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA },
|
---|
190 |
|
---|
191 | /* NV */
|
---|
192 | {"GL_NV_depth_clamp", NV_DEPTH_CLAMP },
|
---|
193 | {"GL_NV_fence", NV_FENCE },
|
---|
194 | {"GL_NV_fog_distance", NV_FOG_DISTANCE },
|
---|
195 | {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM },
|
---|
196 | {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2 },
|
---|
197 | {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION },
|
---|
198 | {"GL_NV_half_float", NV_HALF_FLOAT },
|
---|
199 | {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT },
|
---|
200 | {"GL_NV_point_sprite", NV_POINT_SPRITE },
|
---|
201 | {"GL_NV_register_combiners", NV_REGISTER_COMBINERS },
|
---|
202 | {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2 },
|
---|
203 | {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION },
|
---|
204 | {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4 },
|
---|
205 | {"GL_NV_texture_shader", NV_TEXTURE_SHADER },
|
---|
206 | {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2 },
|
---|
207 | {"GL_NV_vertex_program", NV_VERTEX_PROGRAM },
|
---|
208 | {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1 },
|
---|
209 | {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2 },
|
---|
210 | {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION },
|
---|
211 | {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3 },
|
---|
212 |
|
---|
213 | /* SGI */
|
---|
214 | {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP },
|
---|
215 | };
|
---|
216 |
|
---|
217 | static const struct wined3d_extension_map wgl_extension_map[] =
|
---|
218 | {
|
---|
219 | {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT },
|
---|
220 | {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL },
|
---|
221 | {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH},
|
---|
222 | };
|
---|
223 |
|
---|
224 | /**********************************************************
|
---|
225 | * Utility functions follow
|
---|
226 | **********************************************************/
|
---|
227 |
|
---|
228 | const struct min_lookup minMipLookup[] =
|
---|
229 | {
|
---|
230 | /* NONE POINT LINEAR */
|
---|
231 | {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
|
---|
232 | {{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
|
---|
233 | {{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
|
---|
234 | };
|
---|
235 |
|
---|
236 | const struct min_lookup minMipLookup_noFilter[] =
|
---|
237 | {
|
---|
238 | /* NONE POINT LINEAR */
|
---|
239 | {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
|
---|
240 | {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
|
---|
241 | {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* LINEAR */
|
---|
242 | };
|
---|
243 |
|
---|
244 | const struct min_lookup minMipLookup_noMip[] =
|
---|
245 | {
|
---|
246 | /* NONE POINT LINEAR */
|
---|
247 | {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
|
---|
248 | {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
|
---|
249 | {{GL_LINEAR, GL_LINEAR, GL_LINEAR }}, /* LINEAR */
|
---|
250 | };
|
---|
251 |
|
---|
252 | const GLenum magLookup[] =
|
---|
253 | {
|
---|
254 | /* NONE POINT LINEAR */
|
---|
255 | GL_NEAREST, GL_NEAREST, GL_LINEAR,
|
---|
256 | };
|
---|
257 |
|
---|
258 | const GLenum magLookup_noFilter[] =
|
---|
259 | {
|
---|
260 | /* NONE POINT LINEAR */
|
---|
261 | GL_NEAREST, GL_NEAREST, GL_NEAREST,
|
---|
262 | };
|
---|
263 |
|
---|
264 | /* drawStridedSlow attributes */
|
---|
265 | glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT];
|
---|
266 | glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT];
|
---|
267 | glAttribFunc specular_func_3ubv;
|
---|
268 | glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT];
|
---|
269 | glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT];
|
---|
270 | glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT];
|
---|
271 |
|
---|
272 | /**
|
---|
273 | * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
|
---|
274 | * i.e., there is no GL Context - Get a default rendering context to enable the
|
---|
275 | * function query some info from GL.
|
---|
276 | */
|
---|
277 |
|
---|
278 | struct wined3d_fake_gl_ctx
|
---|
279 | {
|
---|
280 | HDC dc;
|
---|
281 | HWND wnd;
|
---|
282 | HGLRC gl_ctx;
|
---|
283 | HDC restore_dc;
|
---|
284 | HGLRC restore_gl_ctx;
|
---|
285 | };
|
---|
286 |
|
---|
287 | static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx *ctx)
|
---|
288 | {
|
---|
289 | TRACE("Destroying fake GL context.\n");
|
---|
290 |
|
---|
291 | if (!wglMakeCurrent(NULL, NULL))
|
---|
292 | ERR("Failed to disable fake GL context.\n");
|
---|
293 |
|
---|
294 | if (!wglDeleteContext(ctx->gl_ctx))
|
---|
295 | {
|
---|
296 | DWORD err = GetLastError();
|
---|
297 | ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx->gl_ctx, err);
|
---|
298 | }
|
---|
299 |
|
---|
300 | ReleaseDC(ctx->wnd, ctx->dc);
|
---|
301 | DestroyWindow(ctx->wnd);
|
---|
302 |
|
---|
303 | if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
|
---|
304 | ERR("Failed to restore previous GL context.\n");
|
---|
305 | }
|
---|
306 |
|
---|
307 | static void wined3d_create_fake_gl_context_attribs(struct wined3d_fake_gl_ctx *fake_gl_ctx,
|
---|
308 | struct wined3d_gl_info *gl_info, const GLint *ctx_attribs)
|
---|
309 | {
|
---|
310 | HGLRC new_ctx;
|
---|
311 |
|
---|
312 | if (!(gl_info->p_wglCreateContextAttribsARB = (void *)wglGetProcAddress("wglCreateContextAttribsARB")))
|
---|
313 | return;
|
---|
314 |
|
---|
315 | if (!(new_ctx = gl_info->p_wglCreateContextAttribsARB(fake_gl_ctx->dc, NULL, ctx_attribs)))
|
---|
316 | {
|
---|
317 | ERR("Failed to create a context using wglCreateContextAttribsARB(), last error %#x.\n", GetLastError());
|
---|
318 | gl_info->p_wglCreateContextAttribsARB = NULL;
|
---|
319 | return;
|
---|
320 | }
|
---|
321 |
|
---|
322 | if (!wglMakeCurrent(fake_gl_ctx->dc, new_ctx))
|
---|
323 | {
|
---|
324 | ERR("Failed to make new context current, last error %#x.\n", GetLastError());
|
---|
325 | if (!wglDeleteContext(new_ctx))
|
---|
326 | ERR("Failed to delete new context, last error %#x.\n", GetLastError());
|
---|
327 | gl_info->p_wglCreateContextAttribsARB = NULL;
|
---|
328 | return;
|
---|
329 | }
|
---|
330 |
|
---|
331 | if (!wglDeleteContext(fake_gl_ctx->gl_ctx))
|
---|
332 | ERR("Failed to delete old context, last error %#x.\n", GetLastError());
|
---|
333 | fake_gl_ctx->gl_ctx = new_ctx;
|
---|
334 | }
|
---|
335 |
|
---|
336 | /* Do not call while under the GL lock. */
|
---|
337 | #ifdef VBOX
|
---|
338 | static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx, struct VBOXUHGSMI *pHgsmi)
|
---|
339 | #else
|
---|
340 | static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
|
---|
341 | #endif
|
---|
342 | {
|
---|
343 | PIXELFORMATDESCRIPTOR pfd;
|
---|
344 | int iPixelFormat;
|
---|
345 |
|
---|
346 | TRACE("getting context...\n");
|
---|
347 |
|
---|
348 | ctx->restore_dc = wglGetCurrentDC();
|
---|
349 | ctx->restore_gl_ctx = wglGetCurrentContext();
|
---|
350 |
|
---|
351 | /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
|
---|
352 | ctx->wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
|
---|
353 | WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL);
|
---|
354 | if (!ctx->wnd)
|
---|
355 | {
|
---|
356 | ERR("Failed to create a window.\n");
|
---|
357 | goto fail;
|
---|
358 | }
|
---|
359 |
|
---|
360 | ctx->dc = GetDC(ctx->wnd);
|
---|
361 | if (!ctx->dc)
|
---|
362 | {
|
---|
363 | ERR("Failed to get a DC.\n");
|
---|
364 | goto fail;
|
---|
365 | }
|
---|
366 |
|
---|
367 | /* PixelFormat selection */
|
---|
368 | ZeroMemory(&pfd, sizeof(pfd));
|
---|
369 | pfd.nSize = sizeof(pfd);
|
---|
370 | pfd.nVersion = 1;
|
---|
371 | pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW; /* PFD_GENERIC_ACCELERATED */
|
---|
372 | pfd.iPixelType = PFD_TYPE_RGBA;
|
---|
373 | pfd.cColorBits = 32;
|
---|
374 | pfd.iLayerType = PFD_MAIN_PLANE;
|
---|
375 |
|
---|
376 | if (!(iPixelFormat = ChoosePixelFormat(ctx->dc, &pfd)))
|
---|
377 | {
|
---|
378 | /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
|
---|
379 | ERR("Failed to find a suitable pixel format.\n");
|
---|
380 | goto fail;
|
---|
381 | }
|
---|
382 | DescribePixelFormat(ctx->dc, iPixelFormat, sizeof(pfd), &pfd);
|
---|
383 | SetPixelFormat(ctx->dc, iPixelFormat, &pfd);
|
---|
384 |
|
---|
385 | /* Create a GL context. */
|
---|
386 | #ifdef VBOX
|
---|
387 | if (!(ctx->gl_ctx = pVBoxCreateContext(ctx->dc, pHgsmi)))
|
---|
388 | #else
|
---|
389 | if (!(ctx->gl_ctx = wglCreateContext(ctx->dc)))
|
---|
390 | #endif
|
---|
391 | {
|
---|
392 | WARN("Failed to create default context for capabilities initialization.\n");
|
---|
393 | goto fail;
|
---|
394 | }
|
---|
395 |
|
---|
396 | /* Make it the current GL context. */
|
---|
397 | if (!wglMakeCurrent(ctx->dc, ctx->gl_ctx))
|
---|
398 | {
|
---|
399 | ERR("Failed to make fake GL context current.\n");
|
---|
400 | goto fail;
|
---|
401 | }
|
---|
402 |
|
---|
403 | return TRUE;
|
---|
404 |
|
---|
405 | fail:
|
---|
406 | if (ctx->gl_ctx) wglDeleteContext(ctx->gl_ctx);
|
---|
407 | ctx->gl_ctx = NULL;
|
---|
408 | if (ctx->dc) ReleaseDC(ctx->wnd, ctx->dc);
|
---|
409 | ctx->dc = NULL;
|
---|
410 | if (ctx->wnd) DestroyWindow(ctx->wnd);
|
---|
411 | ctx->wnd = NULL;
|
---|
412 | if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
|
---|
413 | ERR("Failed to restore previous GL context.\n");
|
---|
414 |
|
---|
415 | return FALSE;
|
---|
416 | }
|
---|
417 |
|
---|
418 | /* Adjust the amount of used texture memory */
|
---|
419 | #ifndef VBOX_WITH_WDDM
|
---|
420 | unsigned int adapter_adjust_memory(struct wined3d_adapter *adapter, int amount)
|
---|
421 | {
|
---|
422 | adapter->UsedTextureRam += amount;
|
---|
423 | TRACE("Adjusted adapter memory by %d to %d.\n", amount, adapter->UsedTextureRam);
|
---|
424 | return adapter->UsedTextureRam;
|
---|
425 | }
|
---|
426 | #endif
|
---|
427 |
|
---|
428 | static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
|
---|
429 | {
|
---|
430 | HeapFree(GetProcessHeap(), 0, adapter->gl_info.formats);
|
---|
431 | HeapFree(GetProcessHeap(), 0, adapter->cfgs);
|
---|
432 | }
|
---|
433 |
|
---|
434 | ULONG CDECL wined3d_incref(struct wined3d *wined3d)
|
---|
435 | {
|
---|
436 | ULONG refcount = InterlockedIncrement(&wined3d->ref);
|
---|
437 |
|
---|
438 | TRACE("%p increasing refcount to %u.\n", wined3d, refcount);
|
---|
439 |
|
---|
440 | return refcount;
|
---|
441 | }
|
---|
442 |
|
---|
443 | ULONG CDECL wined3d_decref(struct wined3d *wined3d)
|
---|
444 | {
|
---|
445 | ULONG refcount = InterlockedDecrement(&wined3d->ref);
|
---|
446 |
|
---|
447 | TRACE("%p decreasing refcount to %u.\n", wined3d, refcount);
|
---|
448 |
|
---|
449 | if (!refcount)
|
---|
450 | {
|
---|
451 | unsigned int i;
|
---|
452 |
|
---|
453 | for (i = 0; i < wined3d->adapter_count; ++i)
|
---|
454 | {
|
---|
455 | wined3d_adapter_cleanup(&wined3d->adapters[i]);
|
---|
456 | }
|
---|
457 | HeapFree(GetProcessHeap(), 0, wined3d);
|
---|
458 |
|
---|
459 | #ifdef VBOX_WITH_WDDM
|
---|
460 | VBoxExtCheckTerm();
|
---|
461 | #endif
|
---|
462 | }
|
---|
463 |
|
---|
464 | return refcount;
|
---|
465 | }
|
---|
466 |
|
---|
467 | /* Context activation is done by the caller. */
|
---|
468 | static BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
|
---|
469 | {
|
---|
470 | GLuint prog;
|
---|
471 | BOOL ret = FALSE;
|
---|
472 | const char *testcode =
|
---|
473 | "!!ARBvp1.0\n"
|
---|
474 | "PARAM C[66] = { program.env[0..65] };\n"
|
---|
475 | "ADDRESS A0;"
|
---|
476 | "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
|
---|
477 | "ARL A0.x, zero.x;\n"
|
---|
478 | "MOV result.position, C[A0.x + 65];\n"
|
---|
479 | "END\n";
|
---|
480 |
|
---|
481 | while (gl_info->gl_ops.gl.p_glGetError());
|
---|
482 | GL_EXTCALL(glGenProgramsARB(1, &prog));
|
---|
483 | if(!prog) {
|
---|
484 | ERR("Failed to create an ARB offset limit test program\n");
|
---|
485 | }
|
---|
486 | GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
|
---|
487 | GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
---|
488 | strlen(testcode), testcode));
|
---|
489 | if (gl_info->gl_ops.gl.p_glGetError())
|
---|
490 | {
|
---|
491 | TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
|
---|
492 | TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
|
---|
493 | ret = TRUE;
|
---|
494 | } else TRACE("OpenGL implementation allows offsets > 63\n");
|
---|
495 |
|
---|
496 | GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
|
---|
497 | GL_EXTCALL(glDeleteProgramsARB(1, &prog));
|
---|
498 | checkGLcall("ARB vp offset limit test cleanup");
|
---|
499 |
|
---|
500 | return ret;
|
---|
501 | }
|
---|
502 |
|
---|
503 | static BOOL match_amd_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
504 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
505 | {
|
---|
506 | if (card_vendor != HW_VENDOR_AMD) return FALSE;
|
---|
507 | if (device == CARD_AMD_RADEON_9500) return TRUE;
|
---|
508 | if (device == CARD_AMD_RADEON_X700) return TRUE;
|
---|
509 | if (device == CARD_AMD_RADEON_X1600) return TRUE;
|
---|
510 | return FALSE;
|
---|
511 | }
|
---|
512 |
|
---|
513 | static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
514 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
515 | {
|
---|
516 | if (card_vendor == HW_VENDOR_NVIDIA)
|
---|
517 | {
|
---|
518 | if (device == CARD_NVIDIA_GEFORCEFX_5200 ||
|
---|
519 | device == CARD_NVIDIA_GEFORCEFX_5600 ||
|
---|
520 | device == CARD_NVIDIA_GEFORCEFX_5800)
|
---|
521 | {
|
---|
522 | return TRUE;
|
---|
523 | }
|
---|
524 | }
|
---|
525 | return FALSE;
|
---|
526 | }
|
---|
527 |
|
---|
528 | static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
529 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
530 | {
|
---|
531 | /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
|
---|
532 | * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
|
---|
533 | * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
|
---|
534 | *
|
---|
535 | * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
|
---|
536 | * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
|
---|
537 | * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
|
---|
538 | * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
|
---|
539 | * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
|
---|
540 | * the chance that other implementations support them is rather small since Win32 QuickTime uses
|
---|
541 | * DirectDraw, not OpenGL.
|
---|
542 | *
|
---|
543 | * This test has been moved into wined3d_guess_gl_vendor()
|
---|
544 | */
|
---|
545 | if (gl_vendor == GL_VENDOR_APPLE)
|
---|
546 | {
|
---|
547 | return TRUE;
|
---|
548 | }
|
---|
549 | return FALSE;
|
---|
550 | }
|
---|
551 |
|
---|
552 | /* Context activation is done by the caller. */
|
---|
553 | static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
|
---|
554 | {
|
---|
555 | /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
|
---|
556 | * but glTexSubImage from a PBO fails miserably, with the first line repeated over
|
---|
557 | * all the texture. This function detects this bug by its symptom and disables PBOs
|
---|
558 | * if the test fails.
|
---|
559 | *
|
---|
560 | * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
|
---|
561 | * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
|
---|
562 | * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
|
---|
563 | * read back is compared to the original. If they are equal PBOs are assumed to work,
|
---|
564 | * otherwise the PBO extension is disabled. */
|
---|
565 | GLuint texture, pbo;
|
---|
566 | static const unsigned int pattern[] =
|
---|
567 | {
|
---|
568 | 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
|
---|
569 | 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
|
---|
570 | 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
|
---|
571 | 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
|
---|
572 | };
|
---|
573 | unsigned int check[sizeof(pattern) / sizeof(pattern[0])];
|
---|
574 |
|
---|
575 | /* No PBO -> No point in testing them. */
|
---|
576 | if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
|
---|
577 |
|
---|
578 | while (gl_info->gl_ops.gl.p_glGetError());
|
---|
579 | gl_info->gl_ops.gl.p_glGenTextures(1, &texture);
|
---|
580 | gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, texture);
|
---|
581 |
|
---|
582 | gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
---|
583 | 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);
|
---|
584 | checkGLcall("Specifying the PBO test texture");
|
---|
585 |
|
---|
586 | GL_EXTCALL(glGenBuffersARB(1, &pbo));
|
---|
587 | GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo));
|
---|
588 | GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, sizeof(pattern), pattern, GL_STREAM_DRAW_ARB));
|
---|
589 | checkGLcall("Specifying the PBO test pbo");
|
---|
590 |
|
---|
591 | 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);
|
---|
592 | checkGLcall("Loading the PBO test texture");
|
---|
593 |
|
---|
594 | GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
|
---|
595 |
|
---|
596 | gl_info->gl_ops.gl.p_glFinish(); /* just to be sure */
|
---|
597 |
|
---|
598 | memset(check, 0, sizeof(check));
|
---|
599 |
|
---|
600 | gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
|
---|
601 | checkGLcall("Reading back the PBO test texture");
|
---|
602 |
|
---|
603 | gl_info->gl_ops.gl.p_glDeleteTextures(1, &texture);
|
---|
604 | GL_EXTCALL(glDeleteBuffersARB(1, &pbo));
|
---|
605 | checkGLcall("PBO test cleanup");
|
---|
606 |
|
---|
607 | if (memcmp(check, pattern, sizeof(check)))
|
---|
608 | {
|
---|
609 | WARN_(d3d_perf)("PBO test failed, read back data doesn't match original.\n"
|
---|
610 | "Disabling PBOs. This may result in slower performance.\n");
|
---|
611 | gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] = FALSE;
|
---|
612 | }
|
---|
613 | else
|
---|
614 | {
|
---|
615 | TRACE("PBO test successful.\n");
|
---|
616 | }
|
---|
617 | }
|
---|
618 |
|
---|
619 | static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
620 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
621 | {
|
---|
622 | return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE);
|
---|
623 | }
|
---|
624 |
|
---|
625 | static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
626 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
627 | {
|
---|
628 | if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
|
---|
629 | if (card_vendor != HW_VENDOR_AMD) return FALSE;
|
---|
630 | if (device == CARD_AMD_RADEON_X1600) return FALSE;
|
---|
631 | return TRUE;
|
---|
632 | }
|
---|
633 |
|
---|
634 | static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
635 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
636 | {
|
---|
637 | /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
|
---|
638 | * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
|
---|
639 | * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
|
---|
640 | * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
|
---|
641 | * hardcoded
|
---|
642 | *
|
---|
643 | * dx10 cards usually have 64 varyings */
|
---|
644 | return gl_info->limits.glsl_varyings > 44;
|
---|
645 | }
|
---|
646 |
|
---|
647 | static BOOL match_not_dx10_capable(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)
|
---|
649 | {
|
---|
650 | return !match_dx10_capable(gl_info, gl_renderer, gl_vendor, card_vendor, device);
|
---|
651 | }
|
---|
652 |
|
---|
653 | /* A GL context is provided by the caller */
|
---|
654 | static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
655 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
656 | {
|
---|
657 | GLenum error;
|
---|
658 | DWORD data[16];
|
---|
659 |
|
---|
660 | if (!gl_info->supported[EXT_SECONDARY_COLOR])
|
---|
661 | return FALSE;
|
---|
662 |
|
---|
663 | while (gl_info->gl_ops.gl.p_glGetError());
|
---|
664 | GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
|
---|
665 | error = gl_info->gl_ops.gl.p_glGetError();
|
---|
666 |
|
---|
667 | if (error == GL_NO_ERROR)
|
---|
668 | {
|
---|
669 | TRACE("GL Implementation accepts 4 component specular color pointers\n");
|
---|
670 | return TRUE;
|
---|
671 | }
|
---|
672 | else
|
---|
673 | {
|
---|
674 | TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
|
---|
675 | debug_glerror(error));
|
---|
676 | return FALSE;
|
---|
677 | }
|
---|
678 | }
|
---|
679 |
|
---|
680 | /* A GL context is provided by the caller */
|
---|
681 | static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
682 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
683 | {
|
---|
684 | GLuint prog;
|
---|
685 | BOOL ret = FALSE;
|
---|
686 | GLint pos;
|
---|
687 | const char *testcode =
|
---|
688 | "!!ARBvp1.0\n"
|
---|
689 | "OPTION NV_vertex_program2;\n"
|
---|
690 | "MOV result.clip[0], 0.0;\n"
|
---|
691 | "MOV result.position, 0.0;\n"
|
---|
692 | "END\n";
|
---|
693 |
|
---|
694 | if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE;
|
---|
695 |
|
---|
696 | while (gl_info->gl_ops.gl.p_glGetError());
|
---|
697 |
|
---|
698 | GL_EXTCALL(glGenProgramsARB(1, &prog));
|
---|
699 | if(!prog)
|
---|
700 | {
|
---|
701 | ERR("Failed to create the NVvp clip test program\n");
|
---|
702 | return FALSE;
|
---|
703 | }
|
---|
704 | GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
|
---|
705 | GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
---|
706 | strlen(testcode), testcode));
|
---|
707 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
|
---|
708 | if(pos != -1)
|
---|
709 | {
|
---|
710 | WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
|
---|
711 | TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
|
---|
712 | ret = TRUE;
|
---|
713 | while (gl_info->gl_ops.gl.p_glGetError());
|
---|
714 | }
|
---|
715 | else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
|
---|
716 |
|
---|
717 | GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
|
---|
718 | GL_EXTCALL(glDeleteProgramsARB(1, &prog));
|
---|
719 | checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
|
---|
720 |
|
---|
721 | return ret;
|
---|
722 | }
|
---|
723 |
|
---|
724 | /* Context activation is done by the caller. */
|
---|
725 | static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
726 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
727 | {
|
---|
728 | char data[4 * 4 * 4];
|
---|
729 | GLuint tex, fbo;
|
---|
730 | GLenum status;
|
---|
731 |
|
---|
732 | if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE;
|
---|
733 |
|
---|
734 | memset(data, 0xcc, sizeof(data));
|
---|
735 |
|
---|
736 | gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
|
---|
737 | gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
|
---|
738 | gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
---|
739 | gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
---|
740 | 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);
|
---|
741 | checkGLcall("glTexImage2D");
|
---|
742 |
|
---|
743 | gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
|
---|
744 | gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
---|
745 | gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
|
---|
746 | checkGLcall("glFramebufferTexture2D");
|
---|
747 |
|
---|
748 | status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
---|
749 | if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
|
---|
750 | checkGLcall("glCheckFramebufferStatus");
|
---|
751 |
|
---|
752 | memset(data, 0x11, sizeof(data));
|
---|
753 | 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);
|
---|
754 | checkGLcall("glTexSubImage2D");
|
---|
755 |
|
---|
756 | gl_info->gl_ops.gl.p_glClearColor(0.996f, 0.729f, 0.745f, 0.792f);
|
---|
757 | gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
|
---|
758 | checkGLcall("glClear");
|
---|
759 |
|
---|
760 | gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
|
---|
761 | checkGLcall("glGetTexImage");
|
---|
762 |
|
---|
763 | gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
---|
764 | gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
---|
765 | gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
|
---|
766 | checkGLcall("glBindTexture");
|
---|
767 |
|
---|
768 | gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
|
---|
769 | gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
|
---|
770 | checkGLcall("glDeleteTextures");
|
---|
771 |
|
---|
772 | return *(DWORD *)data == 0x11111111;
|
---|
773 | }
|
---|
774 |
|
---|
775 | /* Context activation is done by the caller. */
|
---|
776 | static BOOL match_broken_rgba16(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
777 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
778 | {
|
---|
779 | /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
|
---|
780 | * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
|
---|
781 | GLuint tex;
|
---|
782 | GLint size;
|
---|
783 |
|
---|
784 | gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
|
---|
785 | gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
|
---|
786 | gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL);
|
---|
787 | checkGLcall("glTexImage2D");
|
---|
788 |
|
---|
789 | gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &size);
|
---|
790 | checkGLcall("glGetTexLevelParameteriv");
|
---|
791 | TRACE("Real color depth is %d\n", size);
|
---|
792 |
|
---|
793 | gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
|
---|
794 | checkGLcall("glBindTexture");
|
---|
795 | gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
|
---|
796 | checkGLcall("glDeleteTextures");
|
---|
797 |
|
---|
798 | return size < 16;
|
---|
799 | }
|
---|
800 |
|
---|
801 | static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
802 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
803 | {
|
---|
804 | return gl_vendor == GL_VENDOR_FGLRX;
|
---|
805 | }
|
---|
806 |
|
---|
807 | static BOOL match_r200(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
808 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
809 | {
|
---|
810 | if (card_vendor != HW_VENDOR_AMD) return FALSE;
|
---|
811 | if (device == CARD_AMD_RADEON_8500) return TRUE;
|
---|
812 | return FALSE;
|
---|
813 | }
|
---|
814 |
|
---|
815 | static BOOL match_broken_arb_fog(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
816 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
817 | {
|
---|
818 | DWORD data[4];
|
---|
819 | GLuint tex, fbo;
|
---|
820 | GLenum status;
|
---|
821 | float color[4] = {0.0f, 1.0f, 0.0f, 0.0f};
|
---|
822 | GLuint prog;
|
---|
823 | GLint err_pos;
|
---|
824 | static const char *program_code =
|
---|
825 | "!!ARBfp1.0\n"
|
---|
826 | "OPTION ARB_fog_linear;\n"
|
---|
827 | "MOV result.color, {1.0, 0.0, 0.0, 0.0};\n"
|
---|
828 | "END\n";
|
---|
829 |
|
---|
830 | if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
|
---|
831 | return FALSE;
|
---|
832 | if (!gl_info->supported[ARB_FRAGMENT_PROGRAM])
|
---|
833 | return FALSE;
|
---|
834 |
|
---|
835 | gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
|
---|
836 | gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
|
---|
837 | gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
---|
838 | gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
---|
839 | 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);
|
---|
840 | checkGLcall("glTexImage2D");
|
---|
841 |
|
---|
842 | gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
|
---|
843 | gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
---|
844 | gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
|
---|
845 | checkGLcall("glFramebufferTexture2D");
|
---|
846 |
|
---|
847 | status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
---|
848 | if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
|
---|
849 | checkGLcall("glCheckFramebufferStatus");
|
---|
850 |
|
---|
851 | gl_info->gl_ops.gl.p_glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
|
---|
852 | gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
|
---|
853 | checkGLcall("glClear");
|
---|
854 | gl_info->gl_ops.gl.p_glViewport(0, 0, 4, 1);
|
---|
855 | checkGLcall("glViewport");
|
---|
856 |
|
---|
857 | gl_info->gl_ops.gl.p_glEnable(GL_FOG);
|
---|
858 | gl_info->gl_ops.gl.p_glFogf(GL_FOG_START, 0.5f);
|
---|
859 | gl_info->gl_ops.gl.p_glFogf(GL_FOG_END, 0.5f);
|
---|
860 | gl_info->gl_ops.gl.p_glFogi(GL_FOG_MODE, GL_LINEAR);
|
---|
861 | gl_info->gl_ops.gl.p_glHint(GL_FOG_HINT, GL_NICEST);
|
---|
862 | gl_info->gl_ops.gl.p_glFogfv(GL_FOG_COLOR, color);
|
---|
863 | checkGLcall("fog setup");
|
---|
864 |
|
---|
865 | GL_EXTCALL(glGenProgramsARB(1, &prog));
|
---|
866 | GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog));
|
---|
867 | GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
---|
868 | strlen(program_code), program_code));
|
---|
869 | gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
---|
870 | checkGLcall("Test fragment program setup");
|
---|
871 |
|
---|
872 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &err_pos);
|
---|
873 | if (err_pos != -1)
|
---|
874 | {
|
---|
875 | const char *error_str;
|
---|
876 | error_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB);
|
---|
877 | FIXME("Fog test program error at position %d: %s\n\n", err_pos, debugstr_a(error_str));
|
---|
878 | }
|
---|
879 |
|
---|
880 | gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP);
|
---|
881 | gl_info->gl_ops.gl.p_glVertex3f(-1.0f, -1.0f, 0.0f);
|
---|
882 | gl_info->gl_ops.gl.p_glVertex3f( 1.0f, -1.0f, 1.0f);
|
---|
883 | gl_info->gl_ops.gl.p_glVertex3f(-1.0f, 1.0f, 0.0f);
|
---|
884 | gl_info->gl_ops.gl.p_glVertex3f( 1.0f, 1.0f, 1.0f);
|
---|
885 | gl_info->gl_ops.gl.p_glEnd();
|
---|
886 | checkGLcall("ARBfp fog test draw");
|
---|
887 |
|
---|
888 | gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
|
---|
889 | checkGLcall("glGetTexImage");
|
---|
890 | data[0] &= 0x00ffffff;
|
---|
891 | data[1] &= 0x00ffffff;
|
---|
892 | data[2] &= 0x00ffffff;
|
---|
893 | data[3] &= 0x00ffffff;
|
---|
894 |
|
---|
895 | gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
---|
896 | gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
|
---|
897 |
|
---|
898 | gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
|
---|
899 | gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
|
---|
900 | gl_info->gl_ops.gl.p_glDisable(GL_FOG);
|
---|
901 | GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0));
|
---|
902 | gl_info->gl_ops.gl.p_glDisable(GL_FRAGMENT_PROGRAM_ARB);
|
---|
903 | GL_EXTCALL(glDeleteProgramsARB(1, &prog));
|
---|
904 | checkGLcall("ARBfp fog test teardown");
|
---|
905 |
|
---|
906 | TRACE("Fog test data: %08x %08x %08x %08x\n", data[0], data[1], data[2], data[3]);
|
---|
907 | return data[0] != 0x00ff0000 || data[3] != 0x0000ff00;
|
---|
908 | }
|
---|
909 |
|
---|
910 | static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
|
---|
911 | {
|
---|
912 | /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
|
---|
913 | * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
|
---|
914 | * allow 48 different offsets or other helper immediate values. */
|
---|
915 | TRACE("Reserving 12 GLSL constants for compiler private use.\n");
|
---|
916 | gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 12);
|
---|
917 | }
|
---|
918 |
|
---|
919 | static void quirk_amd_dx9(struct wined3d_gl_info *gl_info)
|
---|
920 | {
|
---|
921 | /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
|
---|
922 | * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
|
---|
923 | * If real NP2 textures are used, the driver falls back to software. We could just remove the
|
---|
924 | * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconvenient
|
---|
925 | * due to the non-normalized texture coordinates. Thus set an internal extension flag,
|
---|
926 | * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
|
---|
927 | * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
|
---|
928 | *
|
---|
929 | * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
|
---|
930 | * has this extension promoted to core. The extension loading code sets this extension supported
|
---|
931 | * due to that, so this code works on fglrx as well. */
|
---|
932 | if(gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
|
---|
933 | {
|
---|
934 | TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
|
---|
935 | gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
|
---|
936 | gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] = TRUE;
|
---|
937 | }
|
---|
938 | }
|
---|
939 |
|
---|
940 | static void quirk_no_np2(struct wined3d_gl_info *gl_info)
|
---|
941 | {
|
---|
942 | /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
|
---|
943 | * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
|
---|
944 | * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
|
---|
945 | * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
|
---|
946 | * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
|
---|
947 | * We therefore completely remove ARB_tex_npot from the list of supported extensions.
|
---|
948 | *
|
---|
949 | * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
|
---|
950 | * triggering the software fallback. There is not much we can do here apart from disabling the
|
---|
951 | * software-emulated extension and re-enable ARB_tex_rect (which was previously disabled
|
---|
952 | * in wined3d_adapter_init_gl_caps).
|
---|
953 | * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
|
---|
954 | * post-processing effects in the game "Max Payne 2").
|
---|
955 | * The behaviour can be verified through a simple test app attached in bugreport #14724. */
|
---|
956 | TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
|
---|
957 | gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
|
---|
958 | gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE;
|
---|
959 | }
|
---|
960 |
|
---|
961 | static void quirk_texcoord_w(struct wined3d_gl_info *gl_info)
|
---|
962 | {
|
---|
963 | /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
|
---|
964 | * with fixed function fragment processing. Ideally this flag should be detected with a test shader
|
---|
965 | * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
|
---|
966 | * do not like vertex shaders in feedback mode and return an error, even though it should be valid
|
---|
967 | * according to the spec.
|
---|
968 | *
|
---|
969 | * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
|
---|
970 | * makes the shader slower and eats instruction slots which should be available to the d3d app.
|
---|
971 | *
|
---|
972 | * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
|
---|
973 | * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
|
---|
974 | * this workaround is activated on cards that do not need it, it won't break things, just affect
|
---|
975 | * performance negatively. */
|
---|
976 | TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
|
---|
977 | gl_info->quirks |= WINED3D_QUIRK_SET_TEXCOORD_W;
|
---|
978 | }
|
---|
979 |
|
---|
980 | static void quirk_clip_varying(struct wined3d_gl_info *gl_info)
|
---|
981 | {
|
---|
982 | gl_info->quirks |= WINED3D_QUIRK_GLSL_CLIP_VARYING;
|
---|
983 | }
|
---|
984 |
|
---|
985 | static void quirk_allows_specular_alpha(struct wined3d_gl_info *gl_info)
|
---|
986 | {
|
---|
987 | gl_info->quirks |= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA;
|
---|
988 | }
|
---|
989 |
|
---|
990 | static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info)
|
---|
991 | {
|
---|
992 | gl_info->quirks |= WINED3D_QUIRK_NV_CLIP_BROKEN;
|
---|
993 | }
|
---|
994 |
|
---|
995 | static void quirk_fbo_tex_update(struct wined3d_gl_info *gl_info)
|
---|
996 | {
|
---|
997 | gl_info->quirks |= WINED3D_QUIRK_FBO_TEX_UPDATE;
|
---|
998 | }
|
---|
999 |
|
---|
1000 | static void quirk_broken_rgba16(struct wined3d_gl_info *gl_info)
|
---|
1001 | {
|
---|
1002 | gl_info->quirks |= WINED3D_QUIRK_BROKEN_RGBA16;
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 | static void quirk_infolog_spam(struct wined3d_gl_info *gl_info)
|
---|
1006 | {
|
---|
1007 | gl_info->quirks |= WINED3D_QUIRK_INFO_LOG_SPAM;
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | static void quirk_limited_tex_filtering(struct wined3d_gl_info *gl_info)
|
---|
1011 | {
|
---|
1012 | /* Nvidia GeForce 6xxx and 7xxx support accelerated VTF only on a few
|
---|
1013 | selected texture formats. They are apparently the only DX9 class GPUs
|
---|
1014 | supporting VTF.
|
---|
1015 | Also, DX9-era GPUs are somewhat limited with float textures
|
---|
1016 | filtering and blending. */
|
---|
1017 | gl_info->quirks |= WINED3D_QUIRK_LIMITED_TEX_FILTERING;
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 | static void quirk_r200_constants(struct wined3d_gl_info *gl_info)
|
---|
1021 | {
|
---|
1022 | /* The Mesa r200 driver (and there is no other driver for this GPU Wine would run on)
|
---|
1023 | * loads some fog parameters (start, end, exponent, but not the color) into the
|
---|
1024 | * program.
|
---|
1025 | *
|
---|
1026 | * Apparently the fog hardware is only able to handle linear fog with a range of 0.0;1.0,
|
---|
1027 | * and it is the responsibility of the vertex pipeline to handle non-linear fog and
|
---|
1028 | * linear fog with start and end other than 0.0 and 1.0. */
|
---|
1029 | TRACE("Reserving 1 ARB constant for compiler private use.\n");
|
---|
1030 | gl_info->reserved_arb_constants = max(gl_info->reserved_arb_constants, 1);
|
---|
1031 | }
|
---|
1032 |
|
---|
1033 | static void quirk_broken_arb_fog(struct wined3d_gl_info *gl_info)
|
---|
1034 | {
|
---|
1035 | gl_info->quirks |= WINED3D_QUIRK_BROKEN_ARB_FOG;
|
---|
1036 | }
|
---|
1037 |
|
---|
1038 | #ifdef VBOX_WITH_WINE_FIX_QUIRKS
|
---|
1039 | static BOOL match_ati_hd4800(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
1040 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
1041 | {
|
---|
1042 | if (card_vendor != HW_VENDOR_AMD) return FALSE;
|
---|
1043 | if (device == CARD_AMD_RADEON_HD4800) return TRUE;
|
---|
1044 | return FALSE;
|
---|
1045 | }
|
---|
1046 |
|
---|
1047 | static void quirk_fullsize_blit(struct wined3d_gl_info *gl_info)
|
---|
1048 | {
|
---|
1049 | gl_info->quirks |= WINED3D_QUIRK_FULLSIZE_BLIT;
|
---|
1050 | }
|
---|
1051 |
|
---|
1052 | #ifdef VBOX_WITH_WDDM
|
---|
1053 | # if 0
|
---|
1054 | static BOOL match_mesa_nvidia(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
1055 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
1056 | {
|
---|
1057 | if (card_vendor != HW_VENDOR_NVIDIA) return FALSE;
|
---|
1058 | if (gl_vendor != GL_VENDOR_MESA) return FALSE;
|
---|
1059 | return TRUE;
|
---|
1060 | }
|
---|
1061 |
|
---|
1062 | static void quirk_no_shader_3(struct wined3d_gl_info *gl_info)
|
---|
1063 | {
|
---|
1064 | int vs_selected_mode, ps_selected_mode;
|
---|
1065 | select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
|
---|
1066 | if (vs_selected_mode != SHADER_GLSL && ps_selected_mode != SHADER_GLSL)
|
---|
1067 | return;
|
---|
1068 |
|
---|
1069 | gl_info->quirks |= WINED3D_QUIRK_NO_SHADER_V3;
|
---|
1070 | }
|
---|
1071 | # endif
|
---|
1072 | #endif
|
---|
1073 |
|
---|
1074 | static BOOL match_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
1075 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
1076 | {
|
---|
1077 | if (card_vendor == HW_VENDOR_INTEL) return TRUE;
|
---|
1078 | if (gl_vendor == HW_VENDOR_INTEL) return TRUE;
|
---|
1079 | return FALSE;
|
---|
1080 | }
|
---|
1081 |
|
---|
1082 | static void quirk_force_blit(struct wined3d_gl_info *gl_info)
|
---|
1083 | {
|
---|
1084 | gl_info->quirks |= WINED3D_QUIRK_FORCE_BLIT;
|
---|
1085 | }
|
---|
1086 | #endif
|
---|
1087 |
|
---|
1088 | struct driver_quirk
|
---|
1089 | {
|
---|
1090 | BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
1091 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device);
|
---|
1092 | void (*apply)(struct wined3d_gl_info *gl_info);
|
---|
1093 | const char *description;
|
---|
1094 | };
|
---|
1095 |
|
---|
1096 | static const struct driver_quirk quirk_table[] =
|
---|
1097 | {
|
---|
1098 | {
|
---|
1099 | match_amd_r300_to_500,
|
---|
1100 | quirk_amd_dx9,
|
---|
1101 | "AMD normalized texrect quirk"
|
---|
1102 | },
|
---|
1103 | {
|
---|
1104 | match_apple,
|
---|
1105 | quirk_apple_glsl_constants,
|
---|
1106 | "Apple GLSL uniform override"
|
---|
1107 | },
|
---|
1108 | {
|
---|
1109 | match_geforce5,
|
---|
1110 | quirk_no_np2,
|
---|
1111 | "Geforce 5 NP2 disable"
|
---|
1112 | },
|
---|
1113 | {
|
---|
1114 | match_apple_intel,
|
---|
1115 | quirk_texcoord_w,
|
---|
1116 | "Init texcoord .w for Apple Intel GPU driver"
|
---|
1117 | },
|
---|
1118 | {
|
---|
1119 | match_apple_nonr500ati,
|
---|
1120 | quirk_texcoord_w,
|
---|
1121 | "Init texcoord .w for Apple ATI >= r600 GPU driver"
|
---|
1122 | },
|
---|
1123 | {
|
---|
1124 | match_dx10_capable,
|
---|
1125 | quirk_clip_varying,
|
---|
1126 | "Reserved varying for gl_ClipPos"
|
---|
1127 | },
|
---|
1128 | {
|
---|
1129 | /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
|
---|
1130 | * GL implementations accept it. The Mac GL is the only implementation known to
|
---|
1131 | * reject it.
|
---|
1132 | *
|
---|
1133 | * If we can pass 4 component specular colors, do it, because (a) we don't have
|
---|
1134 | * to screw around with the data, and (b) the D3D fixed function vertex pipeline
|
---|
1135 | * passes specular alpha to the pixel shader if any is used. Otherwise the
|
---|
1136 | * specular alpha is used to pass the fog coordinate, which we pass to opengl
|
---|
1137 | * via GL_EXT_fog_coord.
|
---|
1138 | */
|
---|
1139 | match_allows_spec_alpha,
|
---|
1140 | quirk_allows_specular_alpha,
|
---|
1141 | "Allow specular alpha quirk"
|
---|
1142 | },
|
---|
1143 | {
|
---|
1144 | match_broken_nv_clip,
|
---|
1145 | quirk_disable_nvvp_clip,
|
---|
1146 | "Apple NV_vertex_program clip bug quirk"
|
---|
1147 | },
|
---|
1148 | {
|
---|
1149 | match_fbo_tex_update,
|
---|
1150 | quirk_fbo_tex_update,
|
---|
1151 | "FBO rebind for attachment updates"
|
---|
1152 | },
|
---|
1153 | {
|
---|
1154 | match_broken_rgba16,
|
---|
1155 | quirk_broken_rgba16,
|
---|
1156 | "True RGBA16 is not available"
|
---|
1157 | },
|
---|
1158 | {
|
---|
1159 | match_fglrx,
|
---|
1160 | quirk_infolog_spam,
|
---|
1161 | "Not printing GLSL infolog"
|
---|
1162 | },
|
---|
1163 | {
|
---|
1164 | match_not_dx10_capable,
|
---|
1165 | quirk_limited_tex_filtering,
|
---|
1166 | "Texture filtering, blending and VTF support is limited"
|
---|
1167 | },
|
---|
1168 | {
|
---|
1169 | match_r200,
|
---|
1170 | quirk_r200_constants,
|
---|
1171 | "r200 vertex shader constants"
|
---|
1172 | },
|
---|
1173 | {
|
---|
1174 | match_broken_arb_fog,
|
---|
1175 | quirk_broken_arb_fog,
|
---|
1176 | "ARBfp fogstart == fogend workaround"
|
---|
1177 | },
|
---|
1178 | #ifdef VBOX_WITH_WINE_FIX_QUIRKS
|
---|
1179 | {
|
---|
1180 | match_ati_hd4800,
|
---|
1181 | quirk_fullsize_blit,
|
---|
1182 | "Fullsize blit"
|
---|
1183 | },
|
---|
1184 | #if 0 //def VBOX_WITH_WDDM
|
---|
1185 | {
|
---|
1186 | match_mesa_nvidia,
|
---|
1187 | quirk_no_shader_3,
|
---|
1188 | "disable shader 3 support"
|
---|
1189 | },
|
---|
1190 | #endif
|
---|
1191 | {
|
---|
1192 | match_intel,
|
---|
1193 | quirk_force_blit,
|
---|
1194 | "force framebuffer blit when possible"
|
---|
1195 | }
|
---|
1196 | #endif
|
---|
1197 | };
|
---|
1198 |
|
---|
1199 | /* Certain applications (Steam) complain if we report an outdated driver version. In general,
|
---|
1200 | * reporting a driver version is moot because we are not the Windows driver, and we have different
|
---|
1201 | * bugs, features, etc.
|
---|
1202 | *
|
---|
1203 | * The driver version has the form "x.y.z.w".
|
---|
1204 | *
|
---|
1205 | * "x" is the Windows version the driver is meant for:
|
---|
1206 | * 4 -> 95/98/NT4
|
---|
1207 | * 5 -> 2000
|
---|
1208 | * 6 -> 2000/XP
|
---|
1209 | * 7 -> Vista
|
---|
1210 | * 8 -> Win 7
|
---|
1211 | *
|
---|
1212 | * "y" is the maximum Direct3D version the driver supports.
|
---|
1213 | * y -> d3d version mapping:
|
---|
1214 | * 11 -> d3d6
|
---|
1215 | * 12 -> d3d7
|
---|
1216 | * 13 -> d3d8
|
---|
1217 | * 14 -> d3d9
|
---|
1218 | * 15 -> d3d10
|
---|
1219 | * 16 -> d3d10.1
|
---|
1220 | * 17 -> d3d11
|
---|
1221 | *
|
---|
1222 | * "z" is the subversion number.
|
---|
1223 | *
|
---|
1224 | * "w" is the vendor specific driver build number.
|
---|
1225 | */
|
---|
1226 |
|
---|
1227 | struct driver_version_information
|
---|
1228 | {
|
---|
1229 | enum wined3d_display_driver driver;
|
---|
1230 | enum wined3d_driver_model driver_model;
|
---|
1231 | const char *driver_name; /* name of Windows driver */
|
---|
1232 | WORD version; /* version word ('y'), contained in low word of DriverVersion.HighPart */
|
---|
1233 | WORD subversion; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
|
---|
1234 | WORD build; /* build number ('w'), contained in low word of DriverVersion.LowPart */
|
---|
1235 | };
|
---|
1236 |
|
---|
1237 | /* The driver version table contains driver information for different devices on several OS versions. */
|
---|
1238 | static const struct driver_version_information driver_version_table[] =
|
---|
1239 | {
|
---|
1240 | /* AMD
|
---|
1241 | * - Radeon HD2x00 (R600) and up supported by current drivers.
|
---|
1242 | * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
|
---|
1243 | * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
|
---|
1244 | * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
|
---|
1245 | {DRIVER_AMD_RAGE_128PRO, DRIVER_MODEL_NT5X, "ati2dvaa.dll", 13, 3279, 0},
|
---|
1246 | {DRIVER_AMD_R100, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6614},
|
---|
1247 | {DRIVER_AMD_R300, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6764},
|
---|
1248 | {DRIVER_AMD_R600, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 8681},
|
---|
1249 | {DRIVER_AMD_R300, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
|
---|
1250 | {DRIVER_AMD_R600, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
|
---|
1251 |
|
---|
1252 | /* Intel
|
---|
1253 | * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
|
---|
1254 | * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
|
---|
1255 | * igxprd32.dll but the GMA800 driver was never updated. */
|
---|
1256 | {DRIVER_INTEL_GMA800, DRIVER_MODEL_NT5X, "ialmrnt5.dll", 14, 10, 3889},
|
---|
1257 | {DRIVER_INTEL_GMA900, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4764},
|
---|
1258 | {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4926},
|
---|
1259 | {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 5218},
|
---|
1260 | {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT6X, "igdumd32.dll", 14, 10, 1504},
|
---|
1261 | {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT6X, "igdumd32.dll", 15, 10, 1666},
|
---|
1262 |
|
---|
1263 | /* Nvidia
|
---|
1264 | * - Geforce6 and newer cards are supported by the current driver (197.x) on XP-Win7
|
---|
1265 | * - GeforceFX support is up to 173.x on <= XP
|
---|
1266 | * - Geforce2MX/3/4 up to 96.x on <= XP
|
---|
1267 | * - TNT/Geforce1/2 up to 71.x on <= XP
|
---|
1268 | * All version numbers used below are from the Linux nvidia drivers. */
|
---|
1269 | {DRIVER_NVIDIA_TNT, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 7186},
|
---|
1270 | {DRIVER_NVIDIA_GEFORCE2MX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 9371},
|
---|
1271 | {DRIVER_NVIDIA_GEFORCEFX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 11, 7516},
|
---|
1272 | {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT5X, "nv4_disp.dll", 15, 12, 6658},
|
---|
1273 | {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT6X, "nvd3dum.dll", 15, 12, 6658},
|
---|
1274 | };
|
---|
1275 |
|
---|
1276 | struct gpu_description
|
---|
1277 | {
|
---|
1278 | WORD vendor; /* reported PCI card vendor ID */
|
---|
1279 | WORD card; /* reported PCI card device ID */
|
---|
1280 | const char *description; /* Description of the card e.g. NVIDIA RIVA TNT */
|
---|
1281 | enum wined3d_display_driver driver;
|
---|
1282 | unsigned int vidmem;
|
---|
1283 | };
|
---|
1284 |
|
---|
1285 | /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
|
---|
1286 | * found on a board containing a specific GPU. */
|
---|
1287 | static const struct gpu_description gpu_description_table[] =
|
---|
1288 | {
|
---|
1289 | /* Nvidia cards */
|
---|
1290 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT, 16 },
|
---|
1291 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT, 32 },
|
---|
1292 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT, 32 },
|
---|
1293 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT, 32 },
|
---|
1294 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX,32 },
|
---|
1295 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX,64 },
|
---|
1296 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX,64 },
|
---|
1297 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX,64, },
|
---|
1298 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX, 64 },
|
---|
1299 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX, 128 },
|
---|
1300 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX, 256 },
|
---|
1301 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6, 64 },
|
---|
1302 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6, 128 },
|
---|
1303 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6, 128 },
|
---|
1304 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6, 256 },
|
---|
1305 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6, 256 },
|
---|
1306 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
|
---|
1307 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
|
---|
1308 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE6, 128 },
|
---|
1309 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8400GS, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE6, 128 },
|
---|
1310 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
|
---|
1311 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE6, 512 },
|
---|
1312 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE6, 320 },
|
---|
1313 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTX, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE6, 768 },
|
---|
1314 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE6, 256 },
|
---|
1315 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9300, "NVIDIA GeForce 9300", DRIVER_NVIDIA_GEFORCE6, 256 },
|
---|
1316 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400M, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE6, 256 },
|
---|
1317 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
|
---|
1318 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
|
---|
1319 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE6, 384 },
|
---|
1320 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE6, 512 },
|
---|
1321 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_210, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE6, 512 },
|
---|
1322 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT220, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE6, 512 },
|
---|
1323 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE6, 512 },
|
---|
1324 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1325 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE6, 896 },
|
---|
1326 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1327 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_315M, "NVIDIA GeForce 315M", DRIVER_NVIDIA_GEFORCE6, 512 },
|
---|
1328 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_320M, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE6, 256},
|
---|
1329 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_410M, "NVIDIA GeForce 410M", DRIVER_NVIDIA_GEFORCE6, 512},
|
---|
1330 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT320M, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1331 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT325M, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1332 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT330, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1333 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS350M, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1334 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT420, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE6, 2048},
|
---|
1335 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT430, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1336 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT440, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1337 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS450, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1338 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE6, 768 },
|
---|
1339 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460M, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_GEFORCE6, 1536},
|
---|
1340 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX465, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1341 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX470, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE6, 1280},
|
---|
1342 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX480, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE6, 1536},
|
---|
1343 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT520, "NVIDIA GeForce GT 520", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1344 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT540M, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1345 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX550, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1346 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT555M, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1347 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560TI, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1348 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1349 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX570, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE6, 1280},
|
---|
1350 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX580, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE6, 1536},
|
---|
1351 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT610, "NVIDIA GeForce GT 610", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1352 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630, "NVIDIA GeForce GT 630", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1353 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630M, "NVIDIA GeForce GT 630M", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1354 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT640M, "NVIDIA GeForce GT 640M", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1355 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT650M, "NVIDIA GeForce GT 650M", DRIVER_NVIDIA_GEFORCE6, 2048},
|
---|
1356 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650, "NVIDIA GeForce GTX 650", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1357 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650TI, "NVIDIA GeForce GTX 650 Ti", DRIVER_NVIDIA_GEFORCE6, 1024},
|
---|
1358 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660, "NVIDIA GeForce GTX 660", DRIVER_NVIDIA_GEFORCE6, 2048},
|
---|
1359 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660TI, "NVIDIA GeForce GTX 660 Ti", DRIVER_NVIDIA_GEFORCE6, 2048},
|
---|
1360 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_GEFORCE6, 2048},
|
---|
1361 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670MX, "NVIDIA GeForce GTX 670MX", DRIVER_NVIDIA_GEFORCE6, 3072},
|
---|
1362 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX680, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_GEFORCE6, 2048},
|
---|
1363 | {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770M, "NVIDIA GeForce GTX 770M", DRIVER_NVIDIA_GEFORCE6, 3072},
|
---|
1364 |
|
---|
1365 | /* AMD cards */
|
---|
1366 | {HW_VENDOR_AMD, CARD_AMD_RAGE_128PRO, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO, 16 },
|
---|
1367 | {HW_VENDOR_AMD, CARD_AMD_RADEON_7200, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100, 32 },
|
---|
1368 | {HW_VENDOR_AMD, CARD_AMD_RADEON_8500, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100, 64 },
|
---|
1369 | {HW_VENDOR_AMD, CARD_AMD_RADEON_9500, "ATI Radeon 9500", DRIVER_AMD_R300, 64 },
|
---|
1370 | {HW_VENDOR_AMD, CARD_AMD_RADEON_XPRESS_200M, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300, 64 },
|
---|
1371 | {HW_VENDOR_AMD, CARD_AMD_RADEON_X700, "ATI Radeon X700 SE", DRIVER_AMD_R300, 128 },
|
---|
1372 | {HW_VENDOR_AMD, CARD_AMD_RADEON_X1600, "ATI Radeon X1600 Series", DRIVER_AMD_R300, 128 },
|
---|
1373 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2350, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600, 256 },
|
---|
1374 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2600, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600, 256 },
|
---|
1375 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2900, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600, 512 },
|
---|
1376 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3200, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600, 128 },
|
---|
1377 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4200M, "ATI Mobility Radeon HD 4200", DRIVER_AMD_R600, 256 },
|
---|
1378 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4350, "ATI Radeon HD 4350", DRIVER_AMD_R600, 256 },
|
---|
1379 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4600, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600, 512 },
|
---|
1380 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4700, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600, 512 },
|
---|
1381 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4800, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600, 512 },
|
---|
1382 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5400, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600, 512 },
|
---|
1383 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5600, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600, 512 },
|
---|
1384 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5700, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600, 512 },
|
---|
1385 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5800, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600, 1024},
|
---|
1386 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5900, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600, 1024},
|
---|
1387 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6300, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600, 1024},
|
---|
1388 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6400, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600, 1024},
|
---|
1389 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6410D, "AMD Radeon HD 6410D", DRIVER_AMD_R600, 1024},
|
---|
1390 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6550D, "AMD Radeon HD 6550D", DRIVER_AMD_R600, 1024},
|
---|
1391 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600, 1024},
|
---|
1392 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600M, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600, 512 },
|
---|
1393 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6700, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600, 1024},
|
---|
1394 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6800, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600, 1024},
|
---|
1395 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6900, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600, 2048},
|
---|
1396 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7700, "AMD Radeon HD 7700 Series", DRIVER_AMD_R600, 1024},
|
---|
1397 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7800, "AMD Radeon HD 7800 Series", DRIVER_AMD_R600, 2048},
|
---|
1398 | {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7900, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600, 2048},
|
---|
1399 | /* Intel cards */
|
---|
1400 | {HW_VENDOR_INTEL, CARD_INTEL_830M, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800, 32 },
|
---|
1401 | {HW_VENDOR_INTEL, CARD_INTEL_855GM, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800, 32 },
|
---|
1402 | {HW_VENDOR_INTEL, CARD_INTEL_845G, "Intel(R) 845G", DRIVER_INTEL_GMA800, 32 },
|
---|
1403 | {HW_VENDOR_INTEL, CARD_INTEL_865G, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800, 32 },
|
---|
1404 | {HW_VENDOR_INTEL, CARD_INTEL_915G, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
|
---|
1405 | {HW_VENDOR_INTEL, CARD_INTEL_E7221G, "Intel(R) E7221G", DRIVER_INTEL_GMA900, 64 },
|
---|
1406 | {HW_VENDOR_INTEL, CARD_INTEL_915GM, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
|
---|
1407 | {HW_VENDOR_INTEL, CARD_INTEL_945G, "Intel(R) 945G", DRIVER_INTEL_GMA950, 64 },
|
---|
1408 | {HW_VENDOR_INTEL, CARD_INTEL_945GM, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950, 64 },
|
---|
1409 | {HW_VENDOR_INTEL, CARD_INTEL_945GME, "Intel(R) 945GME", DRIVER_INTEL_GMA950, 64 },
|
---|
1410 | {HW_VENDOR_INTEL, CARD_INTEL_Q35, "Intel(R) Q35", DRIVER_INTEL_GMA950, 64 },
|
---|
1411 | {HW_VENDOR_INTEL, CARD_INTEL_G33, "Intel(R) G33", DRIVER_INTEL_GMA950, 64 },
|
---|
1412 | {HW_VENDOR_INTEL, CARD_INTEL_Q33, "Intel(R) Q33", DRIVER_INTEL_GMA950, 64 },
|
---|
1413 | {HW_VENDOR_INTEL, CARD_INTEL_PNVG, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
|
---|
1414 | {HW_VENDOR_INTEL, CARD_INTEL_PNVM, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
|
---|
1415 | {HW_VENDOR_INTEL, CARD_INTEL_965Q, "Intel(R) 965Q", DRIVER_INTEL_GMA3000, 128},
|
---|
1416 | {HW_VENDOR_INTEL, CARD_INTEL_965G, "Intel(R) 965G", DRIVER_INTEL_GMA3000, 128},
|
---|
1417 | {HW_VENDOR_INTEL, CARD_INTEL_946GZ, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000, 128},
|
---|
1418 | {HW_VENDOR_INTEL, CARD_INTEL_965GM, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000, 128},
|
---|
1419 | {HW_VENDOR_INTEL, CARD_INTEL_965GME, "Intel(R) 965GME", DRIVER_INTEL_GMA3000, 128},
|
---|
1420 | {HW_VENDOR_INTEL, CARD_INTEL_GM45, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000, 512},
|
---|
1421 | {HW_VENDOR_INTEL, CARD_INTEL_IGD, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000, 512},
|
---|
1422 | {HW_VENDOR_INTEL, CARD_INTEL_G45, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000, 512},
|
---|
1423 | {HW_VENDOR_INTEL, CARD_INTEL_Q45, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000, 512},
|
---|
1424 | {HW_VENDOR_INTEL, CARD_INTEL_G41, "Intel(R) G41", DRIVER_INTEL_GMA3000, 512},
|
---|
1425 | {HW_VENDOR_INTEL, CARD_INTEL_B43, "Intel(R) B43", DRIVER_INTEL_GMA3000, 512},
|
---|
1426 | {HW_VENDOR_INTEL, CARD_INTEL_ILKD, "Intel(R) Ironlake Desktop", DRIVER_INTEL_GMA3000, 1024},
|
---|
1427 | {HW_VENDOR_INTEL, CARD_INTEL_ILKM, "Intel(R) Ironlake Mobile", DRIVER_INTEL_GMA3000, 1024},
|
---|
1428 | {HW_VENDOR_INTEL, CARD_INTEL_SNBD, "Intel(R) Sandybridge Desktop", DRIVER_INTEL_GMA3000, 1024},
|
---|
1429 | {HW_VENDOR_INTEL, CARD_INTEL_SNBM, "Intel(R) Sandybridge Mobile", DRIVER_INTEL_GMA3000, 1024},
|
---|
1430 | {HW_VENDOR_INTEL, CARD_INTEL_SNBS, "Intel(R) Sandybridge Server", DRIVER_INTEL_GMA3000, 1024},
|
---|
1431 | {HW_VENDOR_INTEL, CARD_INTEL_IVBD, "Intel(R) Ivybridge Desktop", DRIVER_INTEL_GMA3000, 1024},
|
---|
1432 | {HW_VENDOR_INTEL, CARD_INTEL_IVBM, "Intel(R) Ivybridge Mobile", DRIVER_INTEL_GMA3000, 1024},
|
---|
1433 | {HW_VENDOR_INTEL, CARD_INTEL_IVBS, "Intel(R) Ivybridge Server", DRIVER_INTEL_GMA3000, 1024},
|
---|
1434 | };
|
---|
1435 |
|
---|
1436 | static const struct driver_version_information *get_driver_version_info(enum wined3d_display_driver driver,
|
---|
1437 | enum wined3d_driver_model driver_model)
|
---|
1438 | {
|
---|
1439 | unsigned int i;
|
---|
1440 |
|
---|
1441 | TRACE("Looking up version info for driver=%d driver_model=%d\n", driver, driver_model);
|
---|
1442 | for (i = 0; i < (sizeof(driver_version_table) / sizeof(driver_version_table[0])); i++)
|
---|
1443 | {
|
---|
1444 | const struct driver_version_information *entry = &driver_version_table[i];
|
---|
1445 |
|
---|
1446 | if (entry->driver == driver && entry->driver_model == driver_model)
|
---|
1447 | {
|
---|
1448 | TRACE("Found driver \"%s\", version %u, subversion %u, build %u.\n",
|
---|
1449 | entry->driver_name, entry->version, entry->subversion, entry->build);
|
---|
1450 | return entry;
|
---|
1451 | }
|
---|
1452 | }
|
---|
1453 | return NULL;
|
---|
1454 | }
|
---|
1455 |
|
---|
1456 | static void init_driver_info(struct wined3d_driver_info *driver_info,
|
---|
1457 | enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
|
---|
1458 | {
|
---|
1459 | OSVERSIONINFOW os_version;
|
---|
1460 | WORD driver_os_version;
|
---|
1461 | unsigned int i;
|
---|
1462 | enum wined3d_display_driver driver = DRIVER_UNKNOWN;
|
---|
1463 | enum wined3d_driver_model driver_model;
|
---|
1464 | const struct driver_version_information *version_info;
|
---|
1465 |
|
---|
1466 | if (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
|
---|
1467 | {
|
---|
1468 | TRACE("Overriding PCI vendor ID with 0x%04x.\n", wined3d_settings.pci_vendor_id);
|
---|
1469 | vendor = wined3d_settings.pci_vendor_id;
|
---|
1470 | }
|
---|
1471 | driver_info->vendor = vendor;
|
---|
1472 |
|
---|
1473 | if (wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
|
---|
1474 | {
|
---|
1475 | TRACE("Overriding PCI device ID with 0x%04x.\n", wined3d_settings.pci_device_id);
|
---|
1476 | device = wined3d_settings.pci_device_id;
|
---|
1477 | }
|
---|
1478 | driver_info->device = device;
|
---|
1479 |
|
---|
1480 | /* Set a default amount of video memory (64MB). In general this code isn't used unless the user
|
---|
1481 | * overrides the pci ids to a card which is not in our database. */
|
---|
1482 | driver_info->vidmem = WINE_DEFAULT_VIDMEM;
|
---|
1483 |
|
---|
1484 | memset(&os_version, 0, sizeof(os_version));
|
---|
1485 | os_version.dwOSVersionInfoSize = sizeof(os_version);
|
---|
1486 | if (!GetVersionExW(&os_version))
|
---|
1487 | {
|
---|
1488 | ERR("Failed to get OS version, reporting 2000/XP.\n");
|
---|
1489 | driver_os_version = 6;
|
---|
1490 | driver_model = DRIVER_MODEL_NT5X;
|
---|
1491 | }
|
---|
1492 | else
|
---|
1493 | {
|
---|
1494 | TRACE("OS version %u.%u.\n", os_version.dwMajorVersion, os_version.dwMinorVersion);
|
---|
1495 | switch (os_version.dwMajorVersion)
|
---|
1496 | {
|
---|
1497 | case 4:
|
---|
1498 | /* If needed we could distinguish between 9x and NT4, but this code won't make
|
---|
1499 | * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
|
---|
1500 | */
|
---|
1501 | driver_os_version = 4;
|
---|
1502 | driver_model = DRIVER_MODEL_WIN9X;
|
---|
1503 | break;
|
---|
1504 |
|
---|
1505 | case 5:
|
---|
1506 | driver_os_version = 6;
|
---|
1507 | driver_model = DRIVER_MODEL_NT5X;
|
---|
1508 | break;
|
---|
1509 |
|
---|
1510 | case 6:
|
---|
1511 | if (os_version.dwMinorVersion == 0)
|
---|
1512 | {
|
---|
1513 | driver_os_version = 7;
|
---|
1514 | driver_model = DRIVER_MODEL_NT6X;
|
---|
1515 | }
|
---|
1516 | else if (os_version.dwMinorVersion == 1)
|
---|
1517 | {
|
---|
1518 | driver_os_version = 8;
|
---|
1519 | driver_model = DRIVER_MODEL_NT6X;
|
---|
1520 | }
|
---|
1521 | else
|
---|
1522 | {
|
---|
1523 | if (os_version.dwMinorVersion > 2)
|
---|
1524 | {
|
---|
1525 | FIXME("Unhandled OS version %u.%u, reporting Win 8.\n",
|
---|
1526 | os_version.dwMajorVersion, os_version.dwMinorVersion);
|
---|
1527 | }
|
---|
1528 | driver_os_version = 9;
|
---|
1529 | driver_model = DRIVER_MODEL_NT6X;
|
---|
1530 | }
|
---|
1531 | break;
|
---|
1532 |
|
---|
1533 | default:
|
---|
1534 | FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
|
---|
1535 | os_version.dwMajorVersion, os_version.dwMinorVersion);
|
---|
1536 | driver_os_version = 6;
|
---|
1537 | driver_model = DRIVER_MODEL_NT5X;
|
---|
1538 | break;
|
---|
1539 | }
|
---|
1540 | }
|
---|
1541 |
|
---|
1542 | /* When we reach this stage we always have a vendor or device id (it can be a default one).
|
---|
1543 | * This means that unless the ids are overridden, we will always find a GPU description. */
|
---|
1544 | for (i = 0; i < (sizeof(gpu_description_table) / sizeof(gpu_description_table[0])); i++)
|
---|
1545 | {
|
---|
1546 | if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].card)
|
---|
1547 | {
|
---|
1548 | TRACE("Found card %04x:%04x in driver DB.\n", vendor, device);
|
---|
1549 |
|
---|
1550 | driver_info->description = gpu_description_table[i].description;
|
---|
1551 | driver_info->vidmem = gpu_description_table[i].vidmem * 1024*1024;
|
---|
1552 | driver = gpu_description_table[i].driver;
|
---|
1553 | break;
|
---|
1554 | }
|
---|
1555 | }
|
---|
1556 |
|
---|
1557 | if (wined3d_settings.emulated_textureram)
|
---|
1558 | {
|
---|
1559 | TRACE("Overriding amount of video memory with %u bytes.\n", wined3d_settings.emulated_textureram);
|
---|
1560 | driver_info->vidmem = wined3d_settings.emulated_textureram;
|
---|
1561 | }
|
---|
1562 |
|
---|
1563 | /* Try to obtain driver version information for the current Windows version. This fails in
|
---|
1564 | * some cases:
|
---|
1565 | * - the gpu is not available on the currently selected OS version:
|
---|
1566 | * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
|
---|
1567 | * version information for the current Windows version is returned instead of faked info.
|
---|
1568 | * We do the same and assume the default Windows version to emulate is WinXP.
|
---|
1569 | *
|
---|
1570 | * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
|
---|
1571 | * For now return the XP driver info. Perhaps later on we should return VESA.
|
---|
1572 | *
|
---|
1573 | * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
|
---|
1574 | * This could be an indication that our database is not up to date, so this should be fixed.
|
---|
1575 | */
|
---|
1576 | version_info = get_driver_version_info(driver, driver_model);
|
---|
1577 | if (version_info)
|
---|
1578 | {
|
---|
1579 | driver_info->name = version_info->driver_name;
|
---|
1580 | driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version);
|
---|
1581 | driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
|
---|
1582 | }
|
---|
1583 | else
|
---|
1584 | {
|
---|
1585 | version_info = get_driver_version_info(driver, DRIVER_MODEL_NT5X);
|
---|
1586 | if (version_info)
|
---|
1587 | {
|
---|
1588 | driver_info->name = version_info->driver_name;
|
---|
1589 | driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version);
|
---|
1590 | driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
|
---|
1591 | }
|
---|
1592 | else
|
---|
1593 | {
|
---|
1594 | driver_info->description = "Direct3D HAL";
|
---|
1595 | driver_info->name = "Display";
|
---|
1596 | driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, 15);
|
---|
1597 | driver_info->version_low = MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
|
---|
1598 |
|
---|
1599 | FIXME("Unable to find a driver/device info for vendor_id=%#x device_id=%#x for driver_model=%d\n",
|
---|
1600 | vendor, device, driver_model);
|
---|
1601 | }
|
---|
1602 | }
|
---|
1603 |
|
---|
1604 | TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n",
|
---|
1605 | driver_info->version_high, driver_info->version_low);
|
---|
1606 | }
|
---|
1607 |
|
---|
1608 | /* Context activation is done by the caller. */
|
---|
1609 | static void fixup_extensions(struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
1610 | enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
|
---|
1611 | {
|
---|
1612 | unsigned int i;
|
---|
1613 |
|
---|
1614 | for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i)
|
---|
1615 | {
|
---|
1616 | if (!quirk_table[i].match(gl_info, gl_renderer, gl_vendor, card_vendor, device)) continue;
|
---|
1617 | TRACE("Applying driver quirk \"%s\".\n", quirk_table[i].description);
|
---|
1618 | quirk_table[i].apply(gl_info);
|
---|
1619 | }
|
---|
1620 |
|
---|
1621 | /* Find out if PBOs work as they are supposed to. */
|
---|
1622 | test_pbo_functionality(gl_info);
|
---|
1623 | }
|
---|
1624 |
|
---|
1625 | static DWORD wined3d_parse_gl_version(const char *gl_version)
|
---|
1626 | {
|
---|
1627 | const char *ptr = gl_version;
|
---|
1628 | int major, minor;
|
---|
1629 |
|
---|
1630 | major = atoi(ptr);
|
---|
1631 | if (major <= 0)
|
---|
1632 | ERR("Invalid OpenGL major version %d.\n", major);
|
---|
1633 |
|
---|
1634 | while (isdigit(*ptr)) ++ptr;
|
---|
1635 | if (*ptr++ != '.')
|
---|
1636 | ERR("Invalid OpenGL version string %s.\n", debugstr_a(gl_version));
|
---|
1637 |
|
---|
1638 | minor = atoi(ptr);
|
---|
1639 |
|
---|
1640 | TRACE("Found OpenGL version %d.%d.\n", major, minor);
|
---|
1641 |
|
---|
1642 | return MAKEDWORD_VERSION(major, minor);
|
---|
1643 | }
|
---|
1644 |
|
---|
1645 | static enum wined3d_gl_vendor wined3d_guess_gl_vendor(const struct wined3d_gl_info *gl_info,
|
---|
1646 | const char *gl_vendor_string, const char *gl_renderer)
|
---|
1647 | {
|
---|
1648 |
|
---|
1649 | /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
|
---|
1650 | * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
|
---|
1651 | * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
|
---|
1652 | *
|
---|
1653 | * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
|
---|
1654 | * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
|
---|
1655 | * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
|
---|
1656 | * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
|
---|
1657 | * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
|
---|
1658 | * the chance that other implementations support them is rather small since Win32 QuickTime uses
|
---|
1659 | * DirectDraw, not OpenGL. */
|
---|
1660 | if (gl_info->supported[APPLE_FENCE]
|
---|
1661 | && gl_info->supported[APPLE_CLIENT_STORAGE]
|
---|
1662 | && gl_info->supported[APPLE_YCBCR_422])
|
---|
1663 | return GL_VENDOR_APPLE;
|
---|
1664 |
|
---|
1665 | if (strstr(gl_vendor_string, "NVIDIA"))
|
---|
1666 | return GL_VENDOR_NVIDIA;
|
---|
1667 |
|
---|
1668 | if (strstr(gl_vendor_string, "ATI"))
|
---|
1669 | return GL_VENDOR_FGLRX;
|
---|
1670 |
|
---|
1671 | if (strstr(gl_vendor_string, "Intel(R)")
|
---|
1672 | /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
|
---|
1673 | || strstr(gl_renderer, "Intel")
|
---|
1674 | || strstr(gl_vendor_string, "Intel Inc."))
|
---|
1675 | {
|
---|
1676 | #if 0//def VBOX_WITH_WINE_FIX_QUIRKS /* check if we still need this: device detection was improved significantly with wine */
|
---|
1677 | if (strstr(gl_renderer, "Mesa"))
|
---|
1678 | return GL_VENDOR_MESA;
|
---|
1679 | #endif
|
---|
1680 | return GL_VENDOR_INTEL;
|
---|
1681 | }
|
---|
1682 |
|
---|
1683 | if (strstr(gl_vendor_string, "Mesa")
|
---|
1684 | || strstr(gl_vendor_string, "X.Org")
|
---|
1685 | || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
|
---|
1686 | || strstr(gl_vendor_string, "DRI R300 Project")
|
---|
1687 | || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
|
---|
1688 | || strstr(gl_vendor_string, "VMware, Inc.")
|
---|
1689 | || strstr(gl_renderer, "Mesa")
|
---|
1690 | || strstr(gl_renderer, "Gallium"))
|
---|
1691 | return GL_VENDOR_MESA;
|
---|
1692 |
|
---|
1693 | FIXME("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
|
---|
1694 | debugstr_a(gl_vendor_string));
|
---|
1695 |
|
---|
1696 | return GL_VENDOR_UNKNOWN;
|
---|
1697 | }
|
---|
1698 |
|
---|
1699 | static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer)
|
---|
1700 | {
|
---|
1701 | if (strstr(gl_vendor_string, "NVIDIA")
|
---|
1702 | || strstr(gl_vendor_string, "Nouveau")
|
---|
1703 | || strstr(gl_vendor_string, "nouveau"))
|
---|
1704 | return HW_VENDOR_NVIDIA;
|
---|
1705 |
|
---|
1706 | if (strstr(gl_vendor_string, "ATI")
|
---|
1707 | || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
|
---|
1708 | || strstr(gl_vendor_string, "X.Org R300 Project")
|
---|
1709 | || strstr(gl_renderer, "AMD")
|
---|
1710 | || strstr(gl_renderer, "R100")
|
---|
1711 | || strstr(gl_renderer, "R200")
|
---|
1712 | || strstr(gl_renderer, "R300")
|
---|
1713 | || strstr(gl_renderer, "R600")
|
---|
1714 | || strstr(gl_renderer, "R700"))
|
---|
1715 | return HW_VENDOR_AMD;
|
---|
1716 |
|
---|
1717 | if (strstr(gl_vendor_string, "Intel(R)")
|
---|
1718 | /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
|
---|
1719 | || strstr(gl_renderer, "Intel")
|
---|
1720 | || strstr(gl_renderer, "i915")
|
---|
1721 | || strstr(gl_vendor_string, "Intel Inc."))
|
---|
1722 | return HW_VENDOR_INTEL;
|
---|
1723 |
|
---|
1724 | if (strstr(gl_vendor_string, "Mesa")
|
---|
1725 | || strstr(gl_vendor_string, "Brian Paul")
|
---|
1726 | || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
|
---|
1727 | || strstr(gl_vendor_string, "VMware, Inc."))
|
---|
1728 | return HW_VENDOR_SOFTWARE;
|
---|
1729 |
|
---|
1730 | FIXME("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string));
|
---|
1731 |
|
---|
1732 | return HW_VENDOR_NVIDIA;
|
---|
1733 | }
|
---|
1734 |
|
---|
1735 | static UINT d3d_level_from_gl_info(const struct wined3d_gl_info *gl_info)
|
---|
1736 | {
|
---|
1737 | UINT level = 0;
|
---|
1738 |
|
---|
1739 | if (gl_info->supported[ARB_MULTITEXTURE])
|
---|
1740 | level = 6;
|
---|
1741 | if (gl_info->supported[ARB_TEXTURE_COMPRESSION]
|
---|
1742 | && gl_info->supported[ARB_TEXTURE_CUBE_MAP]
|
---|
1743 | && gl_info->supported[ARB_TEXTURE_ENV_DOT3])
|
---|
1744 | level = 7;
|
---|
1745 | if (level == 7 && gl_info->supported[ARB_MULTISAMPLE]
|
---|
1746 | && gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
|
---|
1747 | level = 8;
|
---|
1748 | if (level == 8 && gl_info->supported[ARB_FRAGMENT_PROGRAM]
|
---|
1749 | && gl_info->supported[ARB_VERTEX_SHADER])
|
---|
1750 | level = 9;
|
---|
1751 | if (level == 9 && gl_info->supported[EXT_GPU_SHADER4])
|
---|
1752 | level = 10;
|
---|
1753 |
|
---|
1754 | return level;
|
---|
1755 | }
|
---|
1756 |
|
---|
1757 | static enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl_info *gl_info,
|
---|
1758 | const char *gl_renderer)
|
---|
1759 | {
|
---|
1760 | UINT d3d_level = d3d_level_from_gl_info(gl_info);
|
---|
1761 | unsigned int i;
|
---|
1762 |
|
---|
1763 | #ifndef VBOX_WITH_WDDM
|
---|
1764 | if (d3d_level >= 10)
|
---|
1765 | #endif
|
---|
1766 | {
|
---|
1767 | static const struct
|
---|
1768 | {
|
---|
1769 | const char *renderer;
|
---|
1770 | enum wined3d_pci_device id;
|
---|
1771 | }
|
---|
1772 | cards[] =
|
---|
1773 | {
|
---|
1774 | {"GTX 770M", CARD_NVIDIA_GEFORCE_GTX770M}, /* Geforce 700 - midend high mobile */
|
---|
1775 | {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680}, /* Geforce 600 - highend */
|
---|
1776 | {"GTX 670MX", CARD_NVIDIA_GEFORCE_GTX670MX}, /* Geforce 600 - highend */
|
---|
1777 | {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670}, /* Geforce 600 - midend high */
|
---|
1778 | {"GTX 660 Ti", CARD_NVIDIA_GEFORCE_GTX660TI}, /* Geforce 600 - midend high */
|
---|
1779 | {"GTX 660", CARD_NVIDIA_GEFORCE_GTX660}, /* Geforce 600 - midend high */
|
---|
1780 | {"GTX 650 Ti", CARD_NVIDIA_GEFORCE_GTX650TI}, /* Geforce 600 - lowend */
|
---|
1781 | {"GTX 650", CARD_NVIDIA_GEFORCE_GTX650}, /* Geforce 600 - lowend */
|
---|
1782 | {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M}, /* Geforce 600 - midend mobile */
|
---|
1783 | {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M}, /* Geforce 600 - midend mobile */
|
---|
1784 | {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M}, /* Geforce 600 - midend mobile */
|
---|
1785 | {"GT 630", CARD_NVIDIA_GEFORCE_GT630}, /* Geforce 600 - lowend */
|
---|
1786 | {"GT 610", CARD_NVIDIA_GEFORCE_GT610}, /* Geforce 600 - lowend */
|
---|
1787 | {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */
|
---|
1788 | {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */
|
---|
1789 | {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI}, /* Geforce 500 - midend */
|
---|
1790 | {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */
|
---|
1791 | {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M}, /* Geforce 500 - midend mobile */
|
---|
1792 | {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550}, /* Geforce 500 - midend */
|
---|
1793 | {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M}, /* Geforce 500 - midend mobile */
|
---|
1794 | {"GT 520", CARD_NVIDIA_GEFORCE_GT520}, /* Geforce 500 - lowend */
|
---|
1795 | {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480}, /* Geforce 400 - highend */
|
---|
1796 | {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470}, /* Geforce 400 - midend high */
|
---|
1797 | {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465}, /* Geforce 400 - midend */
|
---|
1798 | {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M}, /* Geforce 400 - highend mobile */
|
---|
1799 | {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460}, /* Geforce 400 - midend */
|
---|
1800 | {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450}, /* Geforce 400 - midend low */
|
---|
1801 | {"GT 440", CARD_NVIDIA_GEFORCE_GT440}, /* Geforce 400 - lowend */
|
---|
1802 | {"GT 430", CARD_NVIDIA_GEFORCE_GT430}, /* Geforce 400 - lowend */
|
---|
1803 | {"GT 420", CARD_NVIDIA_GEFORCE_GT420}, /* Geforce 400 - lowend */
|
---|
1804 | {"410M", CARD_NVIDIA_GEFORCE_410M}, /* Geforce 400 - lowend mobile */
|
---|
1805 | {"GT 330", CARD_NVIDIA_GEFORCE_GT330}, /* Geforce 300 - highend */
|
---|
1806 | {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
|
---|
1807 | {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
|
---|
1808 | {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
|
---|
1809 | {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
|
---|
1810 | {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M}, /* Geforce 300 - midend mobile */
|
---|
1811 | {"320M", CARD_NVIDIA_GEFORCE_320M}, /* Geforce 300 - midend mobile */
|
---|
1812 | {"315M", CARD_NVIDIA_GEFORCE_315M}, /* Geforce 300 - midend mobile */
|
---|
1813 | {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
|
---|
1814 | {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
|
---|
1815 | {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
|
---|
1816 | {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275}, /* Geforce 200 - midend high */
|
---|
1817 | {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260}, /* Geforce 200 - midend */
|
---|
1818 | {"GT 240", CARD_NVIDIA_GEFORCE_GT240}, /* Geforce 200 - midend */
|
---|
1819 | {"GT 220", CARD_NVIDIA_GEFORCE_GT220}, /* Geforce 200 - lowend */
|
---|
1820 | {"Geforce 310", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
|
---|
1821 | {"Geforce 305", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
|
---|
1822 | {"Geforce 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
|
---|
1823 | {"G 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
|
---|
1824 | {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
|
---|
1825 | {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
|
---|
1826 | {"9800", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
|
---|
1827 | {"GT 140", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
|
---|
1828 | {"9600", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
|
---|
1829 | {"GT 130", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
|
---|
1830 | {"GT 120", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
|
---|
1831 | {"9500", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
|
---|
1832 | {"9400M", CARD_NVIDIA_GEFORCE_9400M}, /* Geforce 9 - lowend */
|
---|
1833 | {"9400", CARD_NVIDIA_GEFORCE_9400GT}, /* Geforce 9 - lowend */
|
---|
1834 | {"9300", CARD_NVIDIA_GEFORCE_9300}, /* Geforce 9 - lowend low */
|
---|
1835 | {"9200", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
|
---|
1836 | {"9100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
|
---|
1837 | {"G 100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
|
---|
1838 | {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX}, /* Geforce 8 - highend high */
|
---|
1839 | {"8800", CARD_NVIDIA_GEFORCE_8800GTS}, /* Geforce 8 - highend */
|
---|
1840 | {"8600M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
|
---|
1841 | {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
|
---|
1842 | {"8700", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
|
---|
1843 | {"8600", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
|
---|
1844 | {"8500", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
|
---|
1845 | {"8400", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
|
---|
1846 | {"8300", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
|
---|
1847 | {"8200", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
|
---|
1848 | {"8100", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
|
---|
1849 | };
|
---|
1850 |
|
---|
1851 | for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
|
---|
1852 | {
|
---|
1853 | if (strstr(gl_renderer, cards[i].renderer))
|
---|
1854 | return cards[i].id;
|
---|
1855 | }
|
---|
1856 |
|
---|
1857 | return PCI_DEVICE_NONE;
|
---|
1858 | }
|
---|
1859 |
|
---|
1860 | /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
|
---|
1861 | * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
|
---|
1862 | */
|
---|
1863 | if (d3d_level >= 9 && gl_info->supported[NV_VERTEX_PROGRAM3])
|
---|
1864 | {
|
---|
1865 | static const struct
|
---|
1866 | {
|
---|
1867 | const char *renderer;
|
---|
1868 | enum wined3d_pci_device id;
|
---|
1869 | }
|
---|
1870 | cards[] =
|
---|
1871 | {
|
---|
1872 | {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
|
---|
1873 | {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
|
---|
1874 | {"7950", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
|
---|
1875 | {"7900", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
|
---|
1876 | {"7800", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
|
---|
1877 | {"7700", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
|
---|
1878 | {"7600", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
|
---|
1879 | {"7400", CARD_NVIDIA_GEFORCE_7400}, /* Geforce 7 - lower medium */
|
---|
1880 | {"7300", CARD_NVIDIA_GEFORCE_7300}, /* Geforce 7 - lowend */
|
---|
1881 | {"6800", CARD_NVIDIA_GEFORCE_6800}, /* Geforce 6 - highend */
|
---|
1882 | {"6700", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
|
---|
1883 | {"6610", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
|
---|
1884 | {"6600", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
|
---|
1885 | };
|
---|
1886 |
|
---|
1887 | for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
|
---|
1888 | {
|
---|
1889 | if (strstr(gl_renderer, cards[i].renderer))
|
---|
1890 | return cards[i].id;
|
---|
1891 | }
|
---|
1892 |
|
---|
1893 | return PCI_DEVICE_NONE;
|
---|
1894 | }
|
---|
1895 |
|
---|
1896 | if (d3d_level >= 9)
|
---|
1897 | {
|
---|
1898 | /* GeforceFX - highend */
|
---|
1899 | if (strstr(gl_renderer, "5800")
|
---|
1900 | || strstr(gl_renderer, "5900")
|
---|
1901 | || strstr(gl_renderer, "5950")
|
---|
1902 | || strstr(gl_renderer, "Quadro FX"))
|
---|
1903 | {
|
---|
1904 | return CARD_NVIDIA_GEFORCEFX_5800;
|
---|
1905 | }
|
---|
1906 |
|
---|
1907 | /* GeforceFX - midend */
|
---|
1908 | if (strstr(gl_renderer, "5600")
|
---|
1909 | || strstr(gl_renderer, "5650")
|
---|
1910 | || strstr(gl_renderer, "5700")
|
---|
1911 | || strstr(gl_renderer, "5750"))
|
---|
1912 | {
|
---|
1913 | return CARD_NVIDIA_GEFORCEFX_5600;
|
---|
1914 | }
|
---|
1915 |
|
---|
1916 | /* GeforceFX - lowend */
|
---|
1917 | return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */
|
---|
1918 | }
|
---|
1919 |
|
---|
1920 | if (d3d_level >= 8)
|
---|
1921 | {
|
---|
1922 | if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4"))
|
---|
1923 | {
|
---|
1924 | return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
|
---|
1925 | }
|
---|
1926 |
|
---|
1927 | return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
|
---|
1928 | }
|
---|
1929 |
|
---|
1930 | if (d3d_level >= 7)
|
---|
1931 | {
|
---|
1932 | if (strstr(gl_renderer, "GeForce4 MX"))
|
---|
1933 | {
|
---|
1934 | return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */
|
---|
1935 | }
|
---|
1936 |
|
---|
1937 | if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR"))
|
---|
1938 | {
|
---|
1939 | return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
|
---|
1940 | }
|
---|
1941 |
|
---|
1942 | if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2"))
|
---|
1943 | {
|
---|
1944 | return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
|
---|
1945 | }
|
---|
1946 |
|
---|
1947 | return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */
|
---|
1948 | }
|
---|
1949 |
|
---|
1950 | if (strstr(gl_renderer, "TNT2"))
|
---|
1951 | {
|
---|
1952 | return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */
|
---|
1953 | }
|
---|
1954 |
|
---|
1955 | return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */
|
---|
1956 | }
|
---|
1957 |
|
---|
1958 | static enum wined3d_pci_device select_card_amd_binary(const struct wined3d_gl_info *gl_info,
|
---|
1959 | const char *gl_renderer)
|
---|
1960 | {
|
---|
1961 | UINT d3d_level = d3d_level_from_gl_info(gl_info);
|
---|
1962 |
|
---|
1963 | /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
|
---|
1964 | *
|
---|
1965 | * Beware: renderer string do not match exact card model,
|
---|
1966 | * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
|
---|
1967 | #ifndef VBOX_WITH_WDDM
|
---|
1968 | if (d3d_level >= 10)
|
---|
1969 | #endif
|
---|
1970 | {
|
---|
1971 | unsigned int i;
|
---|
1972 |
|
---|
1973 | static const struct
|
---|
1974 | {
|
---|
1975 | const char *renderer;
|
---|
1976 | enum wined3d_pci_device id;
|
---|
1977 | }
|
---|
1978 | cards[] =
|
---|
1979 | {
|
---|
1980 | /* Southern Islands */
|
---|
1981 | {"HD 7900", CARD_AMD_RADEON_HD7900},
|
---|
1982 | {"HD 7800", CARD_AMD_RADEON_HD7800},
|
---|
1983 | {"HD 7700", CARD_AMD_RADEON_HD7700},
|
---|
1984 | /* Northern Islands */
|
---|
1985 | {"HD 6970", CARD_AMD_RADEON_HD6900},
|
---|
1986 | {"HD 6900", CARD_AMD_RADEON_HD6900},
|
---|
1987 | {"HD 6800", CARD_AMD_RADEON_HD6800},
|
---|
1988 | {"HD 6770M",CARD_AMD_RADEON_HD6600M},
|
---|
1989 | {"HD 6750M",CARD_AMD_RADEON_HD6600M},
|
---|
1990 | {"HD 6700", CARD_AMD_RADEON_HD6700},
|
---|
1991 | {"HD 6670", CARD_AMD_RADEON_HD6600},
|
---|
1992 | {"HD 6630M",CARD_AMD_RADEON_HD6600M},
|
---|
1993 | {"HD 6600M",CARD_AMD_RADEON_HD6600M},
|
---|
1994 | {"HD 6600", CARD_AMD_RADEON_HD6600},
|
---|
1995 | {"HD 6570", CARD_AMD_RADEON_HD6600},
|
---|
1996 | {"HD 6500M",CARD_AMD_RADEON_HD6600M},
|
---|
1997 | {"HD 6500", CARD_AMD_RADEON_HD6600},
|
---|
1998 | {"HD 6400", CARD_AMD_RADEON_HD6400},
|
---|
1999 | {"HD 6300", CARD_AMD_RADEON_HD6300},
|
---|
2000 | {"HD 6200", CARD_AMD_RADEON_HD6300},
|
---|
2001 | /* Evergreen */
|
---|
2002 | {"HD 5870", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS PRO */
|
---|
2003 | {"HD 5850", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS XT */
|
---|
2004 | {"HD 5800", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS HD58xx generic renderer string */
|
---|
2005 | {"HD 5770", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER XT */
|
---|
2006 | {"HD 5750", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER LE */
|
---|
2007 | {"HD 5700", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER HD57xx generic renderer string */
|
---|
2008 | {"HD 5670", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD XT */
|
---|
2009 | {"HD 5570", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
|
---|
2010 | {"HD 5550", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
|
---|
2011 | {"HD 5450", CARD_AMD_RADEON_HD5400}, /* Radeon EG CEDAR PRO */
|
---|
2012 | {"HD 5000", CARD_AMD_RADEON_HD5600}, /* Defaulting to HD 5600 */
|
---|
2013 | /* R700 */
|
---|
2014 | {"HD 4890", CARD_AMD_RADEON_HD4800}, /* Radeon RV790 */
|
---|
2015 | {"HD 4870", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
|
---|
2016 | {"HD 4850", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
|
---|
2017 | {"HD 4830", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
|
---|
2018 | {"HD 4800", CARD_AMD_RADEON_HD4800}, /* Radeon RV7xx HD48xx generic renderer string */
|
---|
2019 | {"HD 4770", CARD_AMD_RADEON_HD4700}, /* Radeon RV740 */
|
---|
2020 | {"HD 4700", CARD_AMD_RADEON_HD4700}, /* Radeon RV7xx HD47xx generic renderer string */
|
---|
2021 | {"HD 4670", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
|
---|
2022 | {"HD 4650", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
|
---|
2023 | {"HD 4600", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
|
---|
2024 | {"HD 4550", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
|
---|
2025 | {"HD 4350", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
|
---|
2026 | /* R600/R700 integrated */
|
---|
2027 | {"HD 4200M", CARD_AMD_RADEON_HD4200M},
|
---|
2028 | {"HD 3300", CARD_AMD_RADEON_HD3200},
|
---|
2029 | {"HD 3200", CARD_AMD_RADEON_HD3200},
|
---|
2030 | {"HD 3100", CARD_AMD_RADEON_HD3200},
|
---|
2031 | /* R600 */
|
---|
2032 | {"HD 3870", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
|
---|
2033 | {"HD 3850", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
|
---|
2034 | {"HD 2900", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
|
---|
2035 | {"HD 3830", CARD_AMD_RADEON_HD2600}, /* China-only midend */
|
---|
2036 | {"HD 3690", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
|
---|
2037 | {"HD 3650", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
|
---|
2038 | {"HD 2600", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
|
---|
2039 | {"HD 3470", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
|
---|
2040 | {"HD 3450", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
|
---|
2041 | {"HD 3430", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
|
---|
2042 | {"HD 3400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
|
---|
2043 | {"HD 2400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
|
---|
2044 | {"HD 2350", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
|
---|
2045 | };
|
---|
2046 |
|
---|
2047 | for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
|
---|
2048 | {
|
---|
2049 | if (strstr(gl_renderer, cards[i].renderer))
|
---|
2050 | return cards[i].id;
|
---|
2051 | }
|
---|
2052 |
|
---|
2053 | return PCI_DEVICE_NONE;
|
---|
2054 | }
|
---|
2055 |
|
---|
2056 | if (d3d_level >= 9)
|
---|
2057 | {
|
---|
2058 | /* Radeon R5xx */
|
---|
2059 | if (strstr(gl_renderer, "X1600")
|
---|
2060 | || strstr(gl_renderer, "X1650")
|
---|
2061 | || strstr(gl_renderer, "X1800")
|
---|
2062 | || strstr(gl_renderer, "X1900")
|
---|
2063 | || strstr(gl_renderer, "X1950"))
|
---|
2064 | {
|
---|
2065 | return CARD_AMD_RADEON_X1600;
|
---|
2066 | }
|
---|
2067 |
|
---|
2068 | /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
|
---|
2069 | * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
|
---|
2070 | if (strstr(gl_renderer, "X700")
|
---|
2071 | || strstr(gl_renderer, "X800")
|
---|
2072 | || strstr(gl_renderer, "X850")
|
---|
2073 | || strstr(gl_renderer, "X1300")
|
---|
2074 | || strstr(gl_renderer, "X1400")
|
---|
2075 | || strstr(gl_renderer, "X1450")
|
---|
2076 | || strstr(gl_renderer, "X1550")
|
---|
2077 | || strstr(gl_renderer, "X2300")
|
---|
2078 | || strstr(gl_renderer, "X2500")
|
---|
2079 | || strstr(gl_renderer, "HD 2300")
|
---|
2080 | )
|
---|
2081 | {
|
---|
2082 | return CARD_AMD_RADEON_X700;
|
---|
2083 | }
|
---|
2084 |
|
---|
2085 | /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
|
---|
2086 | if (strstr(gl_renderer, "Radeon Xpress"))
|
---|
2087 | {
|
---|
2088 | return CARD_AMD_RADEON_XPRESS_200M;
|
---|
2089 | }
|
---|
2090 | }
|
---|
2091 |
|
---|
2092 | return PCI_DEVICE_NONE;
|
---|
2093 | }
|
---|
2094 |
|
---|
2095 | static enum wined3d_pci_device select_card_intel(const struct wined3d_gl_info *gl_info,
|
---|
2096 | const char *gl_renderer)
|
---|
2097 | {
|
---|
2098 | unsigned int i;
|
---|
2099 |
|
---|
2100 | static const struct
|
---|
2101 | {
|
---|
2102 | const char *renderer;
|
---|
2103 | enum wined3d_pci_device id;
|
---|
2104 | }
|
---|
2105 | cards[] =
|
---|
2106 | {
|
---|
2107 | /* Ivybridge */
|
---|
2108 | {"Ivybridge Server", CARD_INTEL_IVBS},
|
---|
2109 | {"Ivybridge Mobile", CARD_INTEL_IVBM},
|
---|
2110 | {"Ivybridge Desktop", CARD_INTEL_IVBD},
|
---|
2111 | /* Sandybridge */
|
---|
2112 | {"Sandybridge Server", CARD_INTEL_SNBS},
|
---|
2113 | {"Sandybridge Mobile", CARD_INTEL_SNBM},
|
---|
2114 | {"Sandybridge Desktop", CARD_INTEL_SNBD},
|
---|
2115 | /* Ironlake */
|
---|
2116 | {"Ironlake Mobile", CARD_INTEL_ILKM},
|
---|
2117 | {"Ironlake Desktop", CARD_INTEL_ILKD},
|
---|
2118 | /* G4x */
|
---|
2119 | {"B43", CARD_INTEL_B43},
|
---|
2120 | {"G41", CARD_INTEL_G41},
|
---|
2121 | {"G45", CARD_INTEL_G45},
|
---|
2122 | {"Q45", CARD_INTEL_Q45},
|
---|
2123 | {"Integrated Graphics Device", CARD_INTEL_IGD},
|
---|
2124 | {"GM45", CARD_INTEL_GM45},
|
---|
2125 | /* i965 */
|
---|
2126 | {"965GME", CARD_INTEL_965GME},
|
---|
2127 | {"965GM", CARD_INTEL_965GM},
|
---|
2128 | {"X3100", CARD_INTEL_965GM}, /* MacOS */
|
---|
2129 | {"946GZ", CARD_INTEL_946GZ},
|
---|
2130 | {"965G", CARD_INTEL_965G},
|
---|
2131 | {"965Q", CARD_INTEL_965Q},
|
---|
2132 | /* i945 */
|
---|
2133 | {"Pineview M", CARD_INTEL_PNVM},
|
---|
2134 | {"Pineview G", CARD_INTEL_PNVG},
|
---|
2135 | {"IGD", CARD_INTEL_PNVG},
|
---|
2136 | {"Q33", CARD_INTEL_Q33},
|
---|
2137 | {"G33", CARD_INTEL_G33},
|
---|
2138 | {"Q35", CARD_INTEL_Q35},
|
---|
2139 | {"945GME", CARD_INTEL_945GME},
|
---|
2140 | {"945GM", CARD_INTEL_945GM},
|
---|
2141 | {"GMA 950", CARD_INTEL_945GM}, /* MacOS */
|
---|
2142 | {"945G", CARD_INTEL_945G},
|
---|
2143 | /* i915 */
|
---|
2144 | {"915GM", CARD_INTEL_915GM},
|
---|
2145 | {"E7221G", CARD_INTEL_E7221G},
|
---|
2146 | {"915G", CARD_INTEL_915G},
|
---|
2147 | /* i8xx */
|
---|
2148 | {"865G", CARD_INTEL_865G},
|
---|
2149 | {"845G", CARD_INTEL_845G},
|
---|
2150 | {"855GM", CARD_INTEL_855GM},
|
---|
2151 | {"830M", CARD_INTEL_830M},
|
---|
2152 | #ifdef VBOX_WITH_WINE_FIX_QUIRKS
|
---|
2153 | {"HD Graphics", CARD_INTEL_SNBM},
|
---|
2154 | #endif
|
---|
2155 | };
|
---|
2156 |
|
---|
2157 | for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
|
---|
2158 | {
|
---|
2159 | if (strstr(gl_renderer, cards[i].renderer))
|
---|
2160 | return cards[i].id;
|
---|
2161 | }
|
---|
2162 |
|
---|
2163 | return PCI_DEVICE_NONE;
|
---|
2164 | }
|
---|
2165 |
|
---|
2166 | static enum wined3d_pci_device select_card_amd_mesa(const struct wined3d_gl_info *gl_info,
|
---|
2167 | const char *gl_renderer)
|
---|
2168 | {
|
---|
2169 | unsigned int i;
|
---|
2170 |
|
---|
2171 | /* 20101109 - These are never returned by current Gallium radeon
|
---|
2172 | * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
|
---|
2173 | *
|
---|
2174 | * These are returned but not handled: RC410, RV380. */
|
---|
2175 | static const struct
|
---|
2176 | {
|
---|
2177 | const char *renderer;
|
---|
2178 | enum wined3d_pci_device id;
|
---|
2179 | }
|
---|
2180 | cards[] =
|
---|
2181 | {
|
---|
2182 | /* Southern Islands */
|
---|
2183 | {"TAHITI", CARD_AMD_RADEON_HD7900},
|
---|
2184 | {"PITCAIRN", CARD_AMD_RADEON_HD7800},
|
---|
2185 | {"CAPE VERDE", CARD_AMD_RADEON_HD7700},
|
---|
2186 | /* Northern Islands */
|
---|
2187 | {"CAYMAN", CARD_AMD_RADEON_HD6900},
|
---|
2188 | {"BARTS", CARD_AMD_RADEON_HD6800},
|
---|
2189 | {"TURKS", CARD_AMD_RADEON_HD6600},
|
---|
2190 | {"SUMO2", CARD_AMD_RADEON_HD6410D}, /* SUMO2 first, because we do a strstr(). */
|
---|
2191 | {"SUMO", CARD_AMD_RADEON_HD6550D},
|
---|
2192 | {"CAICOS", CARD_AMD_RADEON_HD6400},
|
---|
2193 | {"PALM", CARD_AMD_RADEON_HD6300},
|
---|
2194 | /* Evergreen */
|
---|
2195 | {"HEMLOCK", CARD_AMD_RADEON_HD5900},
|
---|
2196 | {"CYPRESS", CARD_AMD_RADEON_HD5800},
|
---|
2197 | {"JUNIPER", CARD_AMD_RADEON_HD5700},
|
---|
2198 | {"REDWOOD", CARD_AMD_RADEON_HD5600},
|
---|
2199 | {"CEDAR", CARD_AMD_RADEON_HD5400},
|
---|
2200 | /* R700 */
|
---|
2201 | {"R700", CARD_AMD_RADEON_HD4800},
|
---|
2202 | {"RV790", CARD_AMD_RADEON_HD4800},
|
---|
2203 | {"RV770", CARD_AMD_RADEON_HD4800},
|
---|
2204 | {"RV740", CARD_AMD_RADEON_HD4700},
|
---|
2205 | {"RV730", CARD_AMD_RADEON_HD4600},
|
---|
2206 | {"RV710", CARD_AMD_RADEON_HD4350},
|
---|
2207 | /* R600/R700 integrated */
|
---|
2208 | {"RS880", CARD_AMD_RADEON_HD4200M},
|
---|
2209 | {"RS780", CARD_AMD_RADEON_HD3200},
|
---|
2210 | /* R600 */
|
---|
2211 | {"R680", CARD_AMD_RADEON_HD2900},
|
---|
2212 | {"R600", CARD_AMD_RADEON_HD2900},
|
---|
2213 | {"RV670", CARD_AMD_RADEON_HD2900},
|
---|
2214 | {"RV635", CARD_AMD_RADEON_HD2600},
|
---|
2215 | {"RV630", CARD_AMD_RADEON_HD2600},
|
---|
2216 | {"RV620", CARD_AMD_RADEON_HD2350},
|
---|
2217 | {"RV610", CARD_AMD_RADEON_HD2350},
|
---|
2218 | /* R500 */
|
---|
2219 | {"R580", CARD_AMD_RADEON_X1600},
|
---|
2220 | {"R520", CARD_AMD_RADEON_X1600},
|
---|
2221 | {"RV570", CARD_AMD_RADEON_X1600},
|
---|
2222 | {"RV560", CARD_AMD_RADEON_X1600},
|
---|
2223 | {"RV535", CARD_AMD_RADEON_X1600},
|
---|
2224 | {"RV530", CARD_AMD_RADEON_X1600},
|
---|
2225 | {"RV516", CARD_AMD_RADEON_X700},
|
---|
2226 | {"RV515", CARD_AMD_RADEON_X700},
|
---|
2227 | /* R400 */
|
---|
2228 | {"R481", CARD_AMD_RADEON_X700},
|
---|
2229 | {"R480", CARD_AMD_RADEON_X700},
|
---|
2230 | {"R430", CARD_AMD_RADEON_X700},
|
---|
2231 | {"R423", CARD_AMD_RADEON_X700},
|
---|
2232 | {"R420", CARD_AMD_RADEON_X700},
|
---|
2233 | {"R410", CARD_AMD_RADEON_X700},
|
---|
2234 | {"RV410", CARD_AMD_RADEON_X700},
|
---|
2235 | /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400MHz */
|
---|
2236 | {"RS740", CARD_AMD_RADEON_XPRESS_200M},
|
---|
2237 | {"RS690", CARD_AMD_RADEON_XPRESS_200M},
|
---|
2238 | {"RS600", CARD_AMD_RADEON_XPRESS_200M},
|
---|
2239 | {"RS485", CARD_AMD_RADEON_XPRESS_200M},
|
---|
2240 | {"RS482", CARD_AMD_RADEON_XPRESS_200M},
|
---|
2241 | {"RS480", CARD_AMD_RADEON_XPRESS_200M},
|
---|
2242 | {"RS400", CARD_AMD_RADEON_XPRESS_200M},
|
---|
2243 | /* R300 */
|
---|
2244 | {"R360", CARD_AMD_RADEON_9500},
|
---|
2245 | {"R350", CARD_AMD_RADEON_9500},
|
---|
2246 | {"R300", CARD_AMD_RADEON_9500},
|
---|
2247 | {"RV370", CARD_AMD_RADEON_9500},
|
---|
2248 | {"RV360", CARD_AMD_RADEON_9500},
|
---|
2249 | {"RV351", CARD_AMD_RADEON_9500},
|
---|
2250 | {"RV350", CARD_AMD_RADEON_9500},
|
---|
2251 | };
|
---|
2252 |
|
---|
2253 | for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
|
---|
2254 | {
|
---|
2255 | if (strstr(gl_renderer, cards[i].renderer))
|
---|
2256 | return cards[i].id;
|
---|
2257 | }
|
---|
2258 |
|
---|
2259 | return PCI_DEVICE_NONE;
|
---|
2260 | }
|
---|
2261 |
|
---|
2262 | static enum wined3d_pci_device select_card_nvidia_mesa(const struct wined3d_gl_info *gl_info,
|
---|
2263 | const char *gl_renderer)
|
---|
2264 | {
|
---|
2265 | unsigned int i;
|
---|
2266 |
|
---|
2267 | static const struct
|
---|
2268 | {
|
---|
2269 | const char *renderer;
|
---|
2270 | enum wined3d_pci_device id;
|
---|
2271 | }
|
---|
2272 | cards[] =
|
---|
2273 | {
|
---|
2274 | /* Kepler */
|
---|
2275 | {"NVE6", CARD_NVIDIA_GEFORCE_GTX770M},
|
---|
2276 | {"NVE4", CARD_NVIDIA_GEFORCE_GTX680},
|
---|
2277 | /* Fermi */
|
---|
2278 | {"NVD9", CARD_NVIDIA_GEFORCE_GT520},
|
---|
2279 | {"NVCF", CARD_NVIDIA_GEFORCE_GTX550},
|
---|
2280 | {"NVCE", CARD_NVIDIA_GEFORCE_GTX560},
|
---|
2281 | {"NVC8", CARD_NVIDIA_GEFORCE_GTX570},
|
---|
2282 | {"NVC4", CARD_NVIDIA_GEFORCE_GTX460},
|
---|
2283 | {"NVC3", CARD_NVIDIA_GEFORCE_GT440},
|
---|
2284 | {"NVC1", CARD_NVIDIA_GEFORCE_GT420},
|
---|
2285 | {"NVC0", CARD_NVIDIA_GEFORCE_GTX480},
|
---|
2286 | /* Tesla */
|
---|
2287 | {"NVAF", CARD_NVIDIA_GEFORCE_GT320M},
|
---|
2288 | {"NVAC", CARD_NVIDIA_GEFORCE_8200},
|
---|
2289 | {"NVAA", CARD_NVIDIA_GEFORCE_8200},
|
---|
2290 | {"NVA8", CARD_NVIDIA_GEFORCE_210},
|
---|
2291 | {"NVA5", CARD_NVIDIA_GEFORCE_GT220},
|
---|
2292 | {"NVA3", CARD_NVIDIA_GEFORCE_GT240},
|
---|
2293 | {"NVA0", CARD_NVIDIA_GEFORCE_GTX280},
|
---|
2294 | {"NV98", CARD_NVIDIA_GEFORCE_9200},
|
---|
2295 | {"NV96", CARD_NVIDIA_GEFORCE_9400GT},
|
---|
2296 | {"NV94", CARD_NVIDIA_GEFORCE_9600GT},
|
---|
2297 | {"NV92", CARD_NVIDIA_GEFORCE_9800GT},
|
---|
2298 | {"NV86", CARD_NVIDIA_GEFORCE_8500GT},
|
---|
2299 | {"NV84", CARD_NVIDIA_GEFORCE_8600GT},
|
---|
2300 | {"NV50", CARD_NVIDIA_GEFORCE_8800GTX},
|
---|
2301 | /* Curie */
|
---|
2302 | {"NV68", CARD_NVIDIA_GEFORCE_6200}, /* 7050 */
|
---|
2303 | {"NV67", CARD_NVIDIA_GEFORCE_6200}, /* 7000M */
|
---|
2304 | {"NV63", CARD_NVIDIA_GEFORCE_6200}, /* 7100 */
|
---|
2305 | {"NV4E", CARD_NVIDIA_GEFORCE_6200}, /* 6100 Go / 6150 Go */
|
---|
2306 | {"NV4C", CARD_NVIDIA_GEFORCE_6200}, /* 6150SE */
|
---|
2307 | {"NV4B", CARD_NVIDIA_GEFORCE_7600},
|
---|
2308 | {"NV4A", CARD_NVIDIA_GEFORCE_6200},
|
---|
2309 | {"NV49", CARD_NVIDIA_GEFORCE_7800GT}, /* 7900 */
|
---|
2310 | {"NV47", CARD_NVIDIA_GEFORCE_7800GT},
|
---|
2311 | {"NV46", CARD_NVIDIA_GEFORCE_7400},
|
---|
2312 | {"NV45", CARD_NVIDIA_GEFORCE_6800},
|
---|
2313 | {"NV44", CARD_NVIDIA_GEFORCE_6200},
|
---|
2314 | {"NV43", CARD_NVIDIA_GEFORCE_6600GT},
|
---|
2315 | {"NV42", CARD_NVIDIA_GEFORCE_6800},
|
---|
2316 | {"NV41", CARD_NVIDIA_GEFORCE_6800},
|
---|
2317 | {"NV40", CARD_NVIDIA_GEFORCE_6800},
|
---|
2318 | /* Rankine */
|
---|
2319 | {"NV38", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5950 Ultra */
|
---|
2320 | {"NV36", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5700/5750 */
|
---|
2321 | {"NV35", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5900 */
|
---|
2322 | {"NV34", CARD_NVIDIA_GEFORCEFX_5200},
|
---|
2323 | {"NV31", CARD_NVIDIA_GEFORCEFX_5600},
|
---|
2324 | {"NV30", CARD_NVIDIA_GEFORCEFX_5800},
|
---|
2325 | /* Kelvin */
|
---|
2326 | {"nv28", CARD_NVIDIA_GEFORCE4_TI4200},
|
---|
2327 | {"nv25", CARD_NVIDIA_GEFORCE4_TI4200},
|
---|
2328 | {"nv20", CARD_NVIDIA_GEFORCE3},
|
---|
2329 | /* Celsius */
|
---|
2330 | {"nv1F", CARD_NVIDIA_GEFORCE4_MX}, /* GF4 MX IGP */
|
---|
2331 | {"nv1A", CARD_NVIDIA_GEFORCE2}, /* GF2 IGP */
|
---|
2332 | {"nv18", CARD_NVIDIA_GEFORCE4_MX},
|
---|
2333 | {"nv17", CARD_NVIDIA_GEFORCE4_MX},
|
---|
2334 | {"nv16", CARD_NVIDIA_GEFORCE2},
|
---|
2335 | {"nv15", CARD_NVIDIA_GEFORCE2},
|
---|
2336 | {"nv11", CARD_NVIDIA_GEFORCE2_MX},
|
---|
2337 | {"nv10", CARD_NVIDIA_GEFORCE},
|
---|
2338 | /* Fahrenheit */
|
---|
2339 | {"nv05", CARD_NVIDIA_RIVA_TNT2},
|
---|
2340 | {"nv04", CARD_NVIDIA_RIVA_TNT},
|
---|
2341 | {"nv03", CARD_NVIDIA_RIVA_128},
|
---|
2342 | };
|
---|
2343 |
|
---|
2344 | for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
|
---|
2345 | {
|
---|
2346 | if (strstr(gl_renderer, cards[i].renderer))
|
---|
2347 | return cards[i].id;
|
---|
2348 | }
|
---|
2349 |
|
---|
2350 | return PCI_DEVICE_NONE;
|
---|
2351 | }
|
---|
2352 |
|
---|
2353 | static const struct gl_vendor_selection
|
---|
2354 | {
|
---|
2355 | enum wined3d_gl_vendor gl_vendor;
|
---|
2356 | const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
|
---|
2357 | enum wined3d_pci_device (*select_card)(const struct wined3d_gl_info *gl_info, const char *gl_renderer);
|
---|
2358 | }
|
---|
2359 | nvidia_gl_vendor_table[] =
|
---|
2360 | {
|
---|
2361 | {GL_VENDOR_NVIDIA, "Nvidia binary driver", select_card_nvidia_binary},
|
---|
2362 | {GL_VENDOR_APPLE, "Apple OSX NVidia binary driver", select_card_nvidia_binary},
|
---|
2363 | {GL_VENDOR_MESA, "Mesa Nouveau driver", select_card_nvidia_mesa},
|
---|
2364 | },
|
---|
2365 | amd_gl_vendor_table[] =
|
---|
2366 | {
|
---|
2367 | {GL_VENDOR_APPLE, "Apple OSX AMD/ATI binary driver", select_card_amd_binary},
|
---|
2368 | {GL_VENDOR_FGLRX, "AMD/ATI binary driver", select_card_amd_binary},
|
---|
2369 | {GL_VENDOR_MESA, "Mesa AMD/ATI driver", select_card_amd_mesa},
|
---|
2370 | },
|
---|
2371 | intel_gl_vendor_table[] =
|
---|
2372 | {
|
---|
2373 | {GL_VENDOR_APPLE, "Apple OSX Intel binary driver", select_card_intel},
|
---|
2374 | {GL_VENDOR_INTEL, "Mesa Intel driver", select_card_intel},
|
---|
2375 | {GL_VENDOR_MESA, "Mesa Intel driver", select_card_intel},
|
---|
2376 | };
|
---|
2377 |
|
---|
2378 | static enum wined3d_pci_device select_card_fallback_nvidia(const struct wined3d_gl_info *gl_info)
|
---|
2379 | {
|
---|
2380 | UINT d3d_level = d3d_level_from_gl_info(gl_info);
|
---|
2381 | if (d3d_level >= 10)
|
---|
2382 | return CARD_NVIDIA_GEFORCE_8800GTX;
|
---|
2383 | if (d3d_level >= 9 && gl_info->supported[NV_VERTEX_PROGRAM3])
|
---|
2384 | return CARD_NVIDIA_GEFORCE_6800;
|
---|
2385 | if (d3d_level >= 9)
|
---|
2386 | #ifndef VBOX_WITH_WDDM
|
---|
2387 | return CARD_NVIDIA_GEFORCEFX_5800;
|
---|
2388 | #else
|
---|
2389 | return CARD_NVIDIA_GEFORCE_6200;
|
---|
2390 | #endif
|
---|
2391 | if (d3d_level >= 8)
|
---|
2392 | return CARD_NVIDIA_GEFORCE3;
|
---|
2393 | if (d3d_level >= 7)
|
---|
2394 | return CARD_NVIDIA_GEFORCE;
|
---|
2395 | if (d3d_level >= 6)
|
---|
2396 | return CARD_NVIDIA_RIVA_TNT;
|
---|
2397 | return CARD_NVIDIA_RIVA_128;
|
---|
2398 | }
|
---|
2399 |
|
---|
2400 | static enum wined3d_pci_device select_card_fallback_amd(const struct wined3d_gl_info *gl_info)
|
---|
2401 | {
|
---|
2402 | UINT d3d_level = d3d_level_from_gl_info(gl_info);
|
---|
2403 | if (d3d_level >= 10)
|
---|
2404 | return CARD_AMD_RADEON_HD2900;
|
---|
2405 | if (d3d_level >= 9)
|
---|
2406 | return CARD_AMD_RADEON_9500;
|
---|
2407 | if (d3d_level >= 8)
|
---|
2408 | return CARD_AMD_RADEON_8500;
|
---|
2409 | if (d3d_level >= 7)
|
---|
2410 | return CARD_AMD_RADEON_7200;
|
---|
2411 | return CARD_AMD_RAGE_128PRO;
|
---|
2412 | }
|
---|
2413 |
|
---|
2414 | static enum wined3d_pci_device select_card_fallback_intel(const struct wined3d_gl_info *gl_info)
|
---|
2415 | {
|
---|
2416 | UINT d3d_level = d3d_level_from_gl_info(gl_info);
|
---|
2417 | if (d3d_level >= 10)
|
---|
2418 | return CARD_INTEL_G45;
|
---|
2419 | return CARD_INTEL_915G;
|
---|
2420 | }
|
---|
2421 |
|
---|
2422 | static enum wined3d_pci_device select_card_handler(const struct gl_vendor_selection *table,
|
---|
2423 | unsigned int table_size, enum wined3d_gl_vendor gl_vendor,
|
---|
2424 | const struct wined3d_gl_info *gl_info, const char *gl_renderer)
|
---|
2425 | {
|
---|
2426 | unsigned int i;
|
---|
2427 |
|
---|
2428 | for (i = 0; i < table_size; ++i)
|
---|
2429 | {
|
---|
2430 | if (table[i].gl_vendor != gl_vendor)
|
---|
2431 | continue;
|
---|
2432 |
|
---|
2433 | TRACE("Applying card selector \"%s\".\n", table[i].description);
|
---|
2434 | return table[i].select_card(gl_info, gl_renderer);
|
---|
2435 | }
|
---|
2436 | FIXME("Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n",
|
---|
2437 | gl_vendor, debugstr_a(gl_renderer));
|
---|
2438 |
|
---|
2439 | return PCI_DEVICE_NONE;
|
---|
2440 | }
|
---|
2441 |
|
---|
2442 | static const struct
|
---|
2443 | {
|
---|
2444 | enum wined3d_pci_vendor card_vendor;
|
---|
2445 | const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
|
---|
2446 | const struct gl_vendor_selection *gl_vendor_selection;
|
---|
2447 | unsigned int gl_vendor_count;
|
---|
2448 | enum wined3d_pci_device (*select_card_fallback)(const struct wined3d_gl_info *gl_info);
|
---|
2449 | }
|
---|
2450 | card_vendor_table[] =
|
---|
2451 | {
|
---|
2452 | {HW_VENDOR_NVIDIA, "Nvidia", nvidia_gl_vendor_table,
|
---|
2453 | sizeof(nvidia_gl_vendor_table) / sizeof(nvidia_gl_vendor_table[0]),
|
---|
2454 | select_card_fallback_nvidia},
|
---|
2455 | {HW_VENDOR_AMD, "AMD", amd_gl_vendor_table,
|
---|
2456 | sizeof(amd_gl_vendor_table) / sizeof(amd_gl_vendor_table[0]),
|
---|
2457 | select_card_fallback_amd},
|
---|
2458 | {HW_VENDOR_INTEL, "Intel", intel_gl_vendor_table,
|
---|
2459 | sizeof(intel_gl_vendor_table) / sizeof(intel_gl_vendor_table[0]),
|
---|
2460 | select_card_fallback_intel},
|
---|
2461 | };
|
---|
2462 |
|
---|
2463 |
|
---|
2464 | static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
|
---|
2465 | enum wined3d_gl_vendor *gl_vendor, enum wined3d_pci_vendor *card_vendor)
|
---|
2466 | {
|
---|
2467 | /* A Direct3D device object contains the PCI id (vendor + device) of the
|
---|
2468 | * videocard which is used for rendering. Various applications use this
|
---|
2469 | * information to get a rough estimation of the features of the card and
|
---|
2470 | * some might use it for enabling 3d effects only on certain types of
|
---|
2471 | * videocards. In some cases games might even use it to work around bugs
|
---|
2472 | * which happen on certain videocards/driver combinations. The problem is
|
---|
2473 | * that OpenGL only exposes a rendering string containing the name of the
|
---|
2474 | * videocard and not the PCI id.
|
---|
2475 | *
|
---|
2476 | * Various games depend on the PCI id, so somehow we need to provide one.
|
---|
2477 | * A simple option is to parse the renderer string and translate this to
|
---|
2478 | * the right PCI id. This is a lot of work because there are more than 200
|
---|
2479 | * GPUs just for Nvidia. Various cards share the same renderer string, so
|
---|
2480 | * the amount of code might be 'small' but there are quite a number of
|
---|
2481 | * exceptions which would make this a pain to maintain. Another way would
|
---|
2482 | * be to query the PCI id from the operating system (assuming this is the
|
---|
2483 | * videocard which is used for rendering which is not always the case).
|
---|
2484 | * This would work but it is not very portable. Second it would not work
|
---|
2485 | * well in, let's say, a remote X situation in which the amount of 3d
|
---|
2486 | * features which can be used is limited.
|
---|
2487 | *
|
---|
2488 | * As said most games only use the PCI id to get an indication of the
|
---|
2489 | * capabilities of the card. It doesn't really matter if the given id is
|
---|
2490 | * the correct one if we return the id of a card with similar 3d features.
|
---|
2491 | *
|
---|
2492 | * The code below checks the OpenGL capabilities of a videocard and matches
|
---|
2493 | * that to a certain level of Direct3D functionality. Once a card passes
|
---|
2494 | * the Direct3D9 check, we know that the card (in case of Nvidia) is at
|
---|
2495 | * least a GeforceFX. To give a better estimate we do a basic check on the
|
---|
2496 | * renderer string but if that won't pass we return a default card. This
|
---|
2497 | * way is better than maintaining a full card database as even without a
|
---|
2498 | * full database we can return a card with similar features. Second the
|
---|
2499 | * size of the database can be made quite small because when you know what
|
---|
2500 | * type of 3d functionality a card has, you know to which GPU family the
|
---|
2501 | * GPU must belong. Because of this you only have to check a small part of
|
---|
2502 | * the renderer string to distinguishes between different models from that
|
---|
2503 | * family.
|
---|
2504 | *
|
---|
2505 | * The code also selects a default amount of video memory which we will
|
---|
2506 | * use for an estimation of the amount of free texture memory. In case of
|
---|
2507 | * real D3D the amount of texture memory includes video memory and system
|
---|
2508 | * memory (to be specific AGP memory or in case of PCIE TurboCache /
|
---|
2509 | * HyperMemory). We don't know how much system memory can be addressed by
|
---|
2510 | * the system but we can make a reasonable estimation about the amount of
|
---|
2511 | * video memory. If the value is slightly wrong it doesn't matter as we
|
---|
2512 | * didn't include AGP-like memory which makes the amount of addressable
|
---|
2513 | * memory higher and second OpenGL isn't that critical it moves to system
|
---|
2514 | * memory behind our backs if really needed. Note that the amount of video
|
---|
2515 | * memory can be overruled using a registry setting. */
|
---|
2516 |
|
---|
2517 | unsigned int i;
|
---|
2518 | enum wined3d_pci_device device;
|
---|
2519 |
|
---|
2520 | for (i = 0; i < (sizeof(card_vendor_table) / sizeof(*card_vendor_table)); ++i)
|
---|
2521 | {
|
---|
2522 | if (card_vendor_table[i].card_vendor != *card_vendor)
|
---|
2523 | continue;
|
---|
2524 |
|
---|
2525 | TRACE("Applying card selector \"%s\".\n", card_vendor_table[i].description);
|
---|
2526 | device = select_card_handler(card_vendor_table[i].gl_vendor_selection,
|
---|
2527 | card_vendor_table[i].gl_vendor_count, *gl_vendor, gl_info, gl_renderer);
|
---|
2528 | if (device != PCI_DEVICE_NONE)
|
---|
2529 | return device;
|
---|
2530 |
|
---|
2531 | TRACE("Unrecognized renderer %s, falling back to default.\n", debugstr_a(gl_renderer));
|
---|
2532 | return card_vendor_table[i].select_card_fallback(gl_info);
|
---|
2533 | }
|
---|
2534 |
|
---|
2535 | FIXME("No card selector available for card vendor %04x (using GL_RENDERER %s).\n",
|
---|
2536 | *card_vendor, debugstr_a(gl_renderer));
|
---|
2537 |
|
---|
2538 | /* Default to generic Nvidia hardware based on the supported OpenGL extensions. */
|
---|
2539 | *card_vendor = HW_VENDOR_NVIDIA;
|
---|
2540 | return select_card_fallback_nvidia(gl_info);
|
---|
2541 | }
|
---|
2542 |
|
---|
2543 | static const struct wined3d_vertex_pipe_ops *select_vertex_implementation(const struct wined3d_gl_info *gl_info,
|
---|
2544 | const struct wined3d_shader_backend_ops *shader_backend_ops)
|
---|
2545 | {
|
---|
2546 | if (shader_backend_ops == &glsl_shader_backend)
|
---|
2547 | return &glsl_vertex_pipe;
|
---|
2548 | return &ffp_vertex_pipe;
|
---|
2549 | }
|
---|
2550 |
|
---|
2551 | static const struct fragment_pipeline *select_fragment_implementation(const struct wined3d_gl_info *gl_info,
|
---|
2552 | const struct wined3d_shader_backend_ops *shader_backend_ops)
|
---|
2553 | {
|
---|
2554 | if (shader_backend_ops == &glsl_shader_backend)
|
---|
2555 | return &glsl_fragment_pipe;
|
---|
2556 | if (shader_backend_ops == &arb_program_shader_backend && gl_info->supported[ARB_FRAGMENT_PROGRAM])
|
---|
2557 | return &arbfp_fragment_pipeline;
|
---|
2558 | if (gl_info->supported[ATI_FRAGMENT_SHADER])
|
---|
2559 | return &atifs_fragment_pipeline;
|
---|
2560 | if (gl_info->supported[NV_REGISTER_COMBINERS] && gl_info->supported[NV_TEXTURE_SHADER2])
|
---|
2561 | return &nvts_fragment_pipeline;
|
---|
2562 | if (gl_info->supported[NV_REGISTER_COMBINERS])
|
---|
2563 | return &nvrc_fragment_pipeline;
|
---|
2564 | return &ffp_fragment_pipeline;
|
---|
2565 | }
|
---|
2566 |
|
---|
2567 | static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info)
|
---|
2568 | {
|
---|
2569 | BOOL glsl = wined3d_settings.glslRequested && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20);
|
---|
2570 |
|
---|
2571 | if (glsl && gl_info->supported[ARB_FRAGMENT_SHADER])
|
---|
2572 | return &glsl_shader_backend;
|
---|
2573 | if (glsl && gl_info->supported[ARB_VERTEX_SHADER])
|
---|
2574 | {
|
---|
2575 | /* Geforce4 cards support GLSL but for vertex shaders only. Further
|
---|
2576 | * its reported GLSL caps are wrong. This combined with the fact that
|
---|
2577 | * GLSL won't offer more features or performance, use ARB shaders only
|
---|
2578 | * on this card. */
|
---|
2579 | if (gl_info->supported[NV_VERTEX_PROGRAM] && !gl_info->supported[NV_VERTEX_PROGRAM2])
|
---|
2580 | return &arb_program_shader_backend;
|
---|
2581 | return &glsl_shader_backend;
|
---|
2582 | }
|
---|
2583 | if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_FRAGMENT_PROGRAM])
|
---|
2584 | return &arb_program_shader_backend;
|
---|
2585 | return &none_shader_backend;
|
---|
2586 | }
|
---|
2587 |
|
---|
2588 | static const struct blit_shader *select_blit_implementation(const struct wined3d_gl_info *gl_info,
|
---|
2589 | const struct wined3d_shader_backend_ops *shader_backend_ops)
|
---|
2590 | {
|
---|
2591 | if ((shader_backend_ops == &glsl_shader_backend
|
---|
2592 | || shader_backend_ops == &arb_program_shader_backend)
|
---|
2593 | && gl_info->supported[ARB_FRAGMENT_PROGRAM])
|
---|
2594 | return &arbfp_blit;
|
---|
2595 | return &ffp_blit;
|
---|
2596 | }
|
---|
2597 |
|
---|
2598 | static void parse_extension_string(struct wined3d_gl_info *gl_info, const char *extensions,
|
---|
2599 | const struct wined3d_extension_map *map, UINT entry_count)
|
---|
2600 | {
|
---|
2601 | while (*extensions)
|
---|
2602 | {
|
---|
2603 | const char *start;
|
---|
2604 | size_t len;
|
---|
2605 | UINT i;
|
---|
2606 |
|
---|
2607 | while (isspace(*extensions))
|
---|
2608 | ++extensions;
|
---|
2609 | start = extensions;
|
---|
2610 | while (!isspace(*extensions) && *extensions)
|
---|
2611 | ++extensions;
|
---|
2612 |
|
---|
2613 | len = extensions - start;
|
---|
2614 | if (!len)
|
---|
2615 | continue;
|
---|
2616 |
|
---|
2617 | TRACE("- %s.\n", debugstr_an(start, len));
|
---|
2618 |
|
---|
2619 | for (i = 0; i < entry_count; ++i)
|
---|
2620 | {
|
---|
2621 | if (len == strlen(map[i].extension_string)
|
---|
2622 | && !memcmp(start, map[i].extension_string, len))
|
---|
2623 | {
|
---|
2624 | TRACE(" FOUND: %s support.\n", map[i].extension_string);
|
---|
2625 | gl_info->supported[map[i].extension] = TRUE;
|
---|
2626 | break;
|
---|
2627 | }
|
---|
2628 | }
|
---|
2629 | }
|
---|
2630 | }
|
---|
2631 |
|
---|
2632 | static void load_gl_funcs(struct wined3d_gl_info *gl_info)
|
---|
2633 | {
|
---|
2634 | #define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
|
---|
2635 | GL_EXT_FUNCS_GEN;
|
---|
2636 | #undef USE_GL_FUNC
|
---|
2637 |
|
---|
2638 | #ifndef USE_WIN32_OPENGL
|
---|
2639 | /* hack: use the functions directly from the TEB table to bypass the thunks */
|
---|
2640 | /* note that we still need the above wglGetProcAddress calls to initialize the table */
|
---|
2641 | gl_info->gl_ops.ext = ((struct opengl_funcs *)NtCurrentTeb()->glTable)->ext;
|
---|
2642 | #endif
|
---|
2643 | }
|
---|
2644 |
|
---|
2645 | static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
|
---|
2646 | {
|
---|
2647 | GLfloat gl_floatv[2];
|
---|
2648 | GLint gl_max;
|
---|
2649 |
|
---|
2650 | gl_info->limits.blends = 1;
|
---|
2651 | gl_info->limits.buffers = 1;
|
---|
2652 | gl_info->limits.textures = 1;
|
---|
2653 | gl_info->limits.texture_coords = 1;
|
---|
2654 | gl_info->limits.fragment_samplers = 1;
|
---|
2655 | gl_info->limits.vertex_samplers = 0;
|
---|
2656 | gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers + gl_info->limits.vertex_samplers;
|
---|
2657 | gl_info->limits.vertex_attribs = 16;
|
---|
2658 | gl_info->limits.glsl_vs_float_constants = 0;
|
---|
2659 | gl_info->limits.glsl_ps_float_constants = 0;
|
---|
2660 | gl_info->limits.arb_vs_float_constants = 0;
|
---|
2661 | gl_info->limits.arb_vs_native_constants = 0;
|
---|
2662 | gl_info->limits.arb_vs_instructions = 0;
|
---|
2663 | gl_info->limits.arb_vs_temps = 0;
|
---|
2664 | gl_info->limits.arb_ps_float_constants = 0;
|
---|
2665 | gl_info->limits.arb_ps_local_constants = 0;
|
---|
2666 | gl_info->limits.arb_ps_instructions = 0;
|
---|
2667 | gl_info->limits.arb_ps_temps = 0;
|
---|
2668 |
|
---|
2669 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max);
|
---|
2670 | gl_info->limits.clipplanes = min(WINED3DMAXUSERCLIPPLANES, gl_max);
|
---|
2671 | TRACE("Clip plane support - max planes %d.\n", gl_max);
|
---|
2672 |
|
---|
2673 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
|
---|
2674 | gl_info->limits.lights = gl_max;
|
---|
2675 | TRACE("Light support - max lights %d.\n", gl_max);
|
---|
2676 |
|
---|
2677 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max);
|
---|
2678 | gl_info->limits.texture_size = gl_max;
|
---|
2679 | TRACE("Maximum texture size support - max texture size %d.\n", gl_max);
|
---|
2680 |
|
---|
2681 | gl_info->gl_ops.gl.p_glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, gl_floatv);
|
---|
2682 | gl_info->limits.pointsize_min = gl_floatv[0];
|
---|
2683 | gl_info->limits.pointsize_max = gl_floatv[1];
|
---|
2684 | TRACE("Maximum point size support - max point size %f.\n", gl_floatv[1]);
|
---|
2685 |
|
---|
2686 | if (gl_info->supported[ARB_MAP_BUFFER_ALIGNMENT])
|
---|
2687 | {
|
---|
2688 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &gl_max);
|
---|
2689 | TRACE("Minimum buffer map alignment: %d.\n", gl_max);
|
---|
2690 | }
|
---|
2691 | else
|
---|
2692 | {
|
---|
2693 | WARN_(d3d_perf)("Driver doesn't guarantee a minimum buffer map alignment.\n");
|
---|
2694 | }
|
---|
2695 | if (gl_info->supported[NV_REGISTER_COMBINERS])
|
---|
2696 | {
|
---|
2697 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max);
|
---|
2698 | gl_info->limits.general_combiners = gl_max;
|
---|
2699 | TRACE("Max general combiners: %d.\n", gl_max);
|
---|
2700 | }
|
---|
2701 | if (gl_info->supported[ARB_DRAW_BUFFERS] && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
|
---|
2702 | {
|
---|
2703 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max);
|
---|
2704 | gl_info->limits.buffers = gl_max;
|
---|
2705 | TRACE("Max draw buffers: %u.\n", gl_max);
|
---|
2706 | }
|
---|
2707 | if (gl_info->supported[ARB_MULTITEXTURE])
|
---|
2708 | {
|
---|
2709 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
|
---|
2710 | gl_info->limits.textures = min(MAX_TEXTURES, gl_max);
|
---|
2711 | TRACE("Max textures: %d.\n", gl_info->limits.textures);
|
---|
2712 |
|
---|
2713 | if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
|
---|
2714 | {
|
---|
2715 | GLint tmp;
|
---|
2716 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &gl_max);
|
---|
2717 | gl_info->limits.texture_coords = min(MAX_TEXTURES, gl_max);
|
---|
2718 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &tmp);
|
---|
2719 | gl_info->limits.fragment_samplers = min(MAX_FRAGMENT_SAMPLERS, tmp);
|
---|
2720 | }
|
---|
2721 | else
|
---|
2722 | {
|
---|
2723 | gl_info->limits.texture_coords = max(gl_info->limits.texture_coords, gl_max);
|
---|
2724 | gl_info->limits.fragment_samplers = max(gl_info->limits.fragment_samplers, gl_max);
|
---|
2725 | }
|
---|
2726 | TRACE("Max texture coords: %d.\n", gl_info->limits.texture_coords);
|
---|
2727 | TRACE("Max fragment samplers: %d.\n", gl_info->limits.fragment_samplers);
|
---|
2728 |
|
---|
2729 | if (gl_info->supported[ARB_VERTEX_SHADER])
|
---|
2730 | {
|
---|
2731 | GLint tmp;
|
---|
2732 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &tmp);
|
---|
2733 | gl_info->limits.vertex_samplers = tmp;
|
---|
2734 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &tmp);
|
---|
2735 | gl_info->limits.combined_samplers = tmp;
|
---|
2736 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &tmp);
|
---|
2737 | gl_info->limits.vertex_attribs = tmp;
|
---|
2738 |
|
---|
2739 | /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
|
---|
2740 | * is known at shader link time. In a vertex shader + pixel shader combination this isn't
|
---|
2741 | * an issue because then the sampler setup only depends on the two shaders. If a pixel
|
---|
2742 | * shader is used with fixed function vertex processing we're fine too because fixed function
|
---|
2743 | * vertex processing doesn't use any samplers. If fixed function fragment processing is
|
---|
2744 | * used we have to make sure that all vertex sampler setups are valid together with all
|
---|
2745 | * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
|
---|
2746 | * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
|
---|
2747 | * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
|
---|
2748 | * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
|
---|
2749 | * a fixed function pipeline anymore.
|
---|
2750 | *
|
---|
2751 | * So this is just a check to check that our assumption holds true. If not, write a warning
|
---|
2752 | * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
|
---|
2753 | if (gl_info->limits.vertex_samplers && gl_info->limits.combined_samplers < 12
|
---|
2754 | && MAX_TEXTURES + gl_info->limits.vertex_samplers > gl_info->limits.combined_samplers)
|
---|
2755 | {
|
---|
2756 | FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
|
---|
2757 | gl_info->limits.vertex_samplers, gl_info->limits.combined_samplers);
|
---|
2758 | FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
|
---|
2759 | if (gl_info->limits.combined_samplers > MAX_TEXTURES)
|
---|
2760 | gl_info->limits.vertex_samplers = gl_info->limits.combined_samplers - MAX_TEXTURES;
|
---|
2761 | else
|
---|
2762 | gl_info->limits.vertex_samplers = 0;
|
---|
2763 | }
|
---|
2764 | }
|
---|
2765 | else
|
---|
2766 | {
|
---|
2767 | gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers;
|
---|
2768 | }
|
---|
2769 | TRACE("Max vertex samplers: %u.\n", gl_info->limits.vertex_samplers);
|
---|
2770 | TRACE("Max combined samplers: %u.\n", gl_info->limits.combined_samplers);
|
---|
2771 | }
|
---|
2772 | if (gl_info->supported[ARB_VERTEX_BLEND])
|
---|
2773 | {
|
---|
2774 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
|
---|
2775 | gl_info->limits.blends = gl_max;
|
---|
2776 | TRACE("Max blends: %u.\n", gl_info->limits.blends);
|
---|
2777 | }
|
---|
2778 | if (gl_info->supported[EXT_TEXTURE3D])
|
---|
2779 | {
|
---|
2780 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &gl_max);
|
---|
2781 | gl_info->limits.texture3d_size = gl_max;
|
---|
2782 | TRACE("Max texture3D size: %d.\n", gl_info->limits.texture3d_size);
|
---|
2783 | }
|
---|
2784 | if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
|
---|
2785 | {
|
---|
2786 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max);
|
---|
2787 | gl_info->limits.anisotropy = gl_max;
|
---|
2788 | TRACE("Max anisotropy: %d.\n", gl_info->limits.anisotropy);
|
---|
2789 | }
|
---|
2790 | if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
|
---|
2791 | {
|
---|
2792 | GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
|
---|
2793 | gl_info->limits.arb_ps_float_constants = gl_max;
|
---|
2794 | TRACE("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info->limits.arb_ps_float_constants);
|
---|
2795 | GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
|
---|
2796 | gl_info->limits.arb_ps_native_constants = gl_max;
|
---|
2797 | TRACE("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
|
---|
2798 | gl_info->limits.arb_ps_native_constants);
|
---|
2799 | GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
|
---|
2800 | gl_info->limits.arb_ps_temps = gl_max;
|
---|
2801 | TRACE("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_ps_temps);
|
---|
2802 | GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
|
---|
2803 | gl_info->limits.arb_ps_instructions = gl_max;
|
---|
2804 | TRACE("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info->limits.arb_ps_instructions);
|
---|
2805 | GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &gl_max));
|
---|
2806 | gl_info->limits.arb_ps_local_constants = gl_max;
|
---|
2807 | TRACE("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info->limits.arb_ps_instructions);
|
---|
2808 | }
|
---|
2809 | if (gl_info->supported[ARB_VERTEX_PROGRAM])
|
---|
2810 | {
|
---|
2811 | GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
|
---|
2812 | gl_info->limits.arb_vs_float_constants = gl_max;
|
---|
2813 | TRACE("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info->limits.arb_vs_float_constants);
|
---|
2814 | GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
|
---|
2815 | gl_info->limits.arb_vs_native_constants = gl_max;
|
---|
2816 | TRACE("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
|
---|
2817 | gl_info->limits.arb_vs_native_constants);
|
---|
2818 | GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
|
---|
2819 | gl_info->limits.arb_vs_temps = gl_max;
|
---|
2820 | TRACE("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_vs_temps);
|
---|
2821 | GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
|
---|
2822 | gl_info->limits.arb_vs_instructions = gl_max;
|
---|
2823 | TRACE("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info->limits.arb_vs_instructions);
|
---|
2824 | }
|
---|
2825 | if (gl_info->supported[ARB_VERTEX_SHADER])
|
---|
2826 | {
|
---|
2827 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &gl_max);
|
---|
2828 | gl_info->limits.glsl_vs_float_constants = gl_max / 4;
|
---|
2829 | TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info->limits.glsl_vs_float_constants);
|
---|
2830 | #ifdef VBOX_WITH_WDDM
|
---|
2831 | /* AFAICT the " / 4" here comes from that we're going to use the glsl_vs/ps_float_constants to create vec4 arrays,
|
---|
2832 | * thus each array element has 4 components, so the actual number of vec4 arrays is GL_MAX_VERTEX/FRAGMENT_UNIFORM_COMPONENTS_ARB / 4
|
---|
2833 | * win8 Aero won't properly work with this constant < 256 in any way,
|
---|
2834 | * while Intel drivers I've encountered this problem with supports vec4 arrays of size > GL_MAX_VERTEX/FRAGMENT_UNIFORM_COMPONENTS_ARB / 4
|
---|
2835 | * so use it here.
|
---|
2836 | * @todo: add logging
|
---|
2837 | * @todo: perhaps should be movet to quirks?
|
---|
2838 | * */
|
---|
2839 | if (gl_info->limits.glsl_vs_float_constants < 256 && gl_max >= 256)
|
---|
2840 | {
|
---|
2841 | DWORD dwVersion = GetVersion();
|
---|
2842 | DWORD dwMajor = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
---|
2843 | DWORD dwMinor = (DWORD)(HIBYTE(LOWORD(dwVersion)));
|
---|
2844 | /* tmp workaround Win8 Aero requirement for 256 */
|
---|
2845 | if (dwMajor > 6 || dwMinor > 1)
|
---|
2846 | {
|
---|
2847 | gl_info->limits.glsl_vs_float_constants = 256;
|
---|
2848 | }
|
---|
2849 | }
|
---|
2850 | #endif
|
---|
2851 | }
|
---|
2852 | if (gl_info->supported[ARB_FRAGMENT_SHADER])
|
---|
2853 | {
|
---|
2854 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &gl_max);
|
---|
2855 | gl_info->limits.glsl_ps_float_constants = gl_max / 4;
|
---|
2856 | TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info->limits.glsl_ps_float_constants);
|
---|
2857 | #ifdef VBOX_WITH_WDDM
|
---|
2858 | /* AFAICT the " / 4" here comes from that we're going to use the glsl_vs/ps_float_constants to create vec4 arrays,
|
---|
2859 | * thus each array element has 4 components, so the actual number of vec4 arrays is GL_MAX_VERTEX/FRAGMENT_UNIFORM_COMPONENTS_ARB / 4
|
---|
2860 | * win8 Aero won't properly work with this constant < 256 in any way,
|
---|
2861 | * while Intel drivers I've encountered this problem with supports vec4 arrays of size > GL_MAX_VERTEX/FRAGMENT_UNIFORM_COMPONENTS_ARB / 4
|
---|
2862 | * so use it here.
|
---|
2863 | * @todo: add logging
|
---|
2864 | * @todo: perhaps should be movet to quirks?
|
---|
2865 | * */
|
---|
2866 | if (gl_info->limits.glsl_ps_float_constants < 256 && gl_max >= 256)
|
---|
2867 | {
|
---|
2868 | DWORD dwVersion = GetVersion();
|
---|
2869 | DWORD dwMajor = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
---|
2870 | DWORD dwMinor = (DWORD)(HIBYTE(LOWORD(dwVersion)));
|
---|
2871 | /* tmp workaround Win8 Aero requirement for 256 */
|
---|
2872 | if (dwMajor > 6 || dwMinor > 1)
|
---|
2873 | {
|
---|
2874 | gl_info->limits.glsl_ps_float_constants = 256;
|
---|
2875 | }
|
---|
2876 | }
|
---|
2877 | #endif
|
---|
2878 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
|
---|
2879 | gl_info->limits.glsl_varyings = gl_max;
|
---|
2880 | TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
|
---|
2881 | }
|
---|
2882 |
|
---|
2883 | if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
|
---|
2884 | gl_info->gl_ops.gl.p_glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess);
|
---|
2885 | else
|
---|
2886 | gl_info->limits.shininess = 128.0f;
|
---|
2887 |
|
---|
2888 | if ((gl_info->supported[ARB_FRAMEBUFFER_OBJECT] || gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
|
---|
2889 | && wined3d_settings.allow_multisampling)
|
---|
2890 | {
|
---|
2891 | gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_SAMPLES, &gl_max);
|
---|
2892 | gl_info->limits.samples = gl_max;
|
---|
2893 | }
|
---|
2894 | }
|
---|
2895 |
|
---|
2896 | /* Context activation is done by the caller. */
|
---|
2897 | static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
|
---|
2898 | {
|
---|
2899 | struct wined3d_driver_info *driver_info = &adapter->driver_info;
|
---|
2900 | const char *gl_vendor_str, *gl_renderer_str, *gl_version_str;
|
---|
2901 | struct wined3d_gl_info *gl_info = &adapter->gl_info;
|
---|
2902 | struct wined3d_vertex_caps vertex_caps;
|
---|
2903 | enum wined3d_pci_vendor card_vendor;
|
---|
2904 | struct fragment_caps fragment_caps;
|
---|
2905 | struct shader_caps shader_caps;
|
---|
2906 | const char *WGL_Extensions = NULL;
|
---|
2907 | const char *GL_Extensions = NULL;
|
---|
2908 | enum wined3d_gl_vendor gl_vendor;
|
---|
2909 | enum wined3d_pci_device device;
|
---|
2910 | DWORD gl_version;
|
---|
2911 | HDC hdc;
|
---|
2912 | unsigned int i;
|
---|
2913 |
|
---|
2914 | TRACE("adapter %p.\n", adapter);
|
---|
2915 |
|
---|
2916 | gl_renderer_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER);
|
---|
2917 | TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str));
|
---|
2918 | if (!gl_renderer_str)
|
---|
2919 | {
|
---|
2920 | ERR("Received a NULL GL_RENDERER.\n");
|
---|
2921 | return FALSE;
|
---|
2922 | }
|
---|
2923 |
|
---|
2924 | gl_vendor_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VENDOR);
|
---|
2925 | TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str));
|
---|
2926 | if (!gl_vendor_str)
|
---|
2927 | {
|
---|
2928 | ERR("Received a NULL GL_VENDOR.\n");
|
---|
2929 | return FALSE;
|
---|
2930 | }
|
---|
2931 |
|
---|
2932 | /* Parse the GL_VERSION field into major and minor information */
|
---|
2933 | gl_version_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VERSION);
|
---|
2934 | TRACE("GL_VERSION: %s.\n", debugstr_a(gl_version_str));
|
---|
2935 | if (!gl_version_str)
|
---|
2936 | {
|
---|
2937 | ERR("Received a NULL GL_VERSION.\n");
|
---|
2938 | return FALSE;
|
---|
2939 | }
|
---|
2940 | gl_version = wined3d_parse_gl_version(gl_version_str);
|
---|
2941 |
|
---|
2942 | /* Parse the gl supported features, in theory enabling parts of our code appropriately. */
|
---|
2943 | GL_Extensions = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_EXTENSIONS);
|
---|
2944 | if (!GL_Extensions)
|
---|
2945 | {
|
---|
2946 | ERR("Received a NULL GL_EXTENSIONS.\n");
|
---|
2947 | return FALSE;
|
---|
2948 | }
|
---|
2949 |
|
---|
2950 | memset(gl_info->supported, 0, sizeof(gl_info->supported));
|
---|
2951 | gl_info->supported[WINED3D_GL_EXT_NONE] = TRUE;
|
---|
2952 |
|
---|
2953 | TRACE("GL extensions reported:\n");
|
---|
2954 | parse_extension_string(gl_info, GL_Extensions, gl_extension_map,
|
---|
2955 | sizeof(gl_extension_map) / sizeof(*gl_extension_map));
|
---|
2956 |
|
---|
2957 | /* Now work out what GL support this card really has. */
|
---|
2958 | load_gl_funcs( gl_info );
|
---|
2959 |
|
---|
2960 | hdc = wglGetCurrentDC();
|
---|
2961 | /* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
|
---|
2962 | if (GL_EXTCALL(wglGetExtensionsStringARB))
|
---|
2963 | WGL_Extensions = (const char *)GL_EXTCALL(wglGetExtensionsStringARB(hdc));
|
---|
2964 | if (!WGL_Extensions)
|
---|
2965 | WARN("WGL extensions not supported.\n");
|
---|
2966 | else
|
---|
2967 | parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map,
|
---|
2968 | sizeof(wgl_extension_map) / sizeof(*wgl_extension_map));
|
---|
2969 |
|
---|
2970 | if (!gl_info->supported[EXT_TEXTURE3D] && gl_version >= MAKEDWORD_VERSION(1, 2))
|
---|
2971 | {
|
---|
2972 | TRACE("GL CORE: GL_EXT_texture3D support.\n");
|
---|
2973 | gl_info->gl_ops.ext.p_glTexImage3DEXT = (void *)gl_info->gl_ops.ext.p_glTexImage3D;
|
---|
2974 | gl_info->gl_ops.ext.p_glTexSubImage3DEXT = gl_info->gl_ops.ext.p_glTexSubImage3D;
|
---|
2975 | gl_info->supported[EXT_TEXTURE3D] = TRUE;
|
---|
2976 | }
|
---|
2977 |
|
---|
2978 | if (!gl_info->supported[NV_POINT_SPRITE] && gl_version >= MAKEDWORD_VERSION(1, 4))
|
---|
2979 | {
|
---|
2980 | TRACE("GL CORE: GL_NV_point_sprite support.\n");
|
---|
2981 | gl_info->gl_ops.ext.p_glPointParameterivNV = gl_info->gl_ops.ext.p_glPointParameteriv;
|
---|
2982 | gl_info->gl_ops.ext.p_glPointParameteriNV = gl_info->gl_ops.ext.p_glPointParameteri;
|
---|
2983 | gl_info->supported[NV_POINT_SPRITE] = TRUE;
|
---|
2984 | }
|
---|
2985 |
|
---|
2986 | if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] && gl_version >= MAKEDWORD_VERSION(2, 0))
|
---|
2987 | {
|
---|
2988 | TRACE("GL CORE: GL_ARB_texture_non_power_of_two support.\n");
|
---|
2989 | gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = TRUE;
|
---|
2990 | }
|
---|
2991 |
|
---|
2992 | if (gl_version >= MAKEDWORD_VERSION(2, 0)) gl_info->supported[WINED3D_GL_VERSION_2_0] = TRUE;
|
---|
2993 |
|
---|
2994 | if (gl_info->supported[APPLE_FENCE])
|
---|
2995 | {
|
---|
2996 | /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
|
---|
2997 | * The apple extension interacts with some other apple exts. Disable the NV
|
---|
2998 | * extension if the apple one is support to prevent confusion in other parts
|
---|
2999 | * of the code. */
|
---|
3000 | gl_info->supported[NV_FENCE] = FALSE;
|
---|
3001 | }
|
---|
3002 | if (gl_info->supported[APPLE_FLOAT_PIXELS])
|
---|
3003 | {
|
---|
3004 | /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
|
---|
3005 | *
|
---|
3006 | * The enums are the same:
|
---|
3007 | * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881a
|
---|
3008 | * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881b
|
---|
3009 | * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
|
---|
3010 | * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
|
---|
3011 | * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140b
|
---|
3012 | */
|
---|
3013 | if (!gl_info->supported[ARB_TEXTURE_FLOAT])
|
---|
3014 | {
|
---|
3015 | TRACE(" IMPLIED: GL_ARB_texture_float support (by GL_APPLE_float_pixels).\n");
|
---|
3016 | gl_info->supported[ARB_TEXTURE_FLOAT] = TRUE;
|
---|
3017 | }
|
---|
3018 | if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
|
---|
3019 | {
|
---|
3020 | TRACE(" IMPLIED: GL_ARB_half_float_pixel support (by GL_APPLE_float_pixels).\n");
|
---|
3021 | gl_info->supported[ARB_HALF_FLOAT_PIXEL] = TRUE;
|
---|
3022 | }
|
---|
3023 | }
|
---|
3024 | if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
|
---|
3025 | {
|
---|
3026 | /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
|
---|
3027 | * functionality. Prefer the ARB extension */
|
---|
3028 | gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] = FALSE;
|
---|
3029 | }
|
---|
3030 | if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
|
---|
3031 | {
|
---|
3032 | TRACE(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
|
---|
3033 | gl_info->supported[NV_TEXGEN_REFLECTION] = TRUE;
|
---|
3034 | }
|
---|
3035 | if (!gl_info->supported[ARB_DEPTH_CLAMP] && gl_info->supported[NV_DEPTH_CLAMP])
|
---|
3036 | {
|
---|
3037 | TRACE(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
|
---|
3038 | gl_info->supported[ARB_DEPTH_CLAMP] = TRUE;
|
---|
3039 | }
|
---|
3040 | if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
|
---|
3041 | {
|
---|
3042 | TRACE(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
|
---|
3043 | gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE;
|
---|
3044 | }
|
---|
3045 | if (!gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] && gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
|
---|
3046 | {
|
---|
3047 | TRACE(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
|
---|
3048 | gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] = TRUE;
|
---|
3049 | }
|
---|
3050 | if (gl_info->supported[NV_TEXTURE_SHADER2])
|
---|
3051 | {
|
---|
3052 | if (gl_info->supported[NV_REGISTER_COMBINERS])
|
---|
3053 | {
|
---|
3054 | /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
|
---|
3055 | * are supported. The nv extensions provide the same functionality as the
|
---|
3056 | * ATI one, and a bit more(signed pixelformats). */
|
---|
3057 | gl_info->supported[ATI_FRAGMENT_SHADER] = FALSE;
|
---|
3058 | }
|
---|
3059 | }
|
---|
3060 | if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
|
---|
3061 | {
|
---|
3062 | /* If we have full NP2 texture support, disable
|
---|
3063 | * GL_ARB_texture_rectangle because we will never use it.
|
---|
3064 | * This saves a few redundant glDisable calls. */
|
---|
3065 | gl_info->supported[ARB_TEXTURE_RECTANGLE] = FALSE;
|
---|
3066 | }
|
---|
3067 | if (gl_info->supported[ATI_FRAGMENT_SHADER])
|
---|
3068 | {
|
---|
3069 | /* Disable NV_register_combiners and fragment shader if this is supported.
|
---|
3070 | * generally the NV extensions are preferred over the ATI ones, and this
|
---|
3071 | * extension is disabled if register_combiners and texture_shader2 are both
|
---|
3072 | * supported. So we reach this place only if we have incomplete NV dxlevel 8
|
---|
3073 | * fragment processing support. */
|
---|
3074 | gl_info->supported[NV_REGISTER_COMBINERS] = FALSE;
|
---|
3075 | gl_info->supported[NV_REGISTER_COMBINERS2] = FALSE;
|
---|
3076 | gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
|
---|
3077 | gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
|
---|
3078 | }
|
---|
3079 | if (gl_info->supported[NV_HALF_FLOAT])
|
---|
3080 | {
|
---|
3081 | /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
|
---|
3082 | gl_info->supported[ARB_HALF_FLOAT_VERTEX] = TRUE;
|
---|
3083 | }
|
---|
3084 | if (gl_info->supported[ARB_FRAMEBUFFER_SRGB] && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
|
---|
3085 | {
|
---|
3086 | /* Current wined3d sRGB infrastructure requires EXT_texture_sRGB_decode
|
---|
3087 | * for GL_ARB_framebuffer_sRGB support (without EXT_texture_sRGB_decode
|
---|
3088 | * we never render to sRGB surfaces). */
|
---|
3089 | gl_info->supported[ARB_FRAMEBUFFER_SRGB] = FALSE;
|
---|
3090 | }
|
---|
3091 | if (gl_info->supported[ARB_OCCLUSION_QUERY])
|
---|
3092 | {
|
---|
3093 | GLint counter_bits;
|
---|
3094 |
|
---|
3095 | GL_EXTCALL(glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB, &counter_bits));
|
---|
3096 | TRACE("Occlusion query counter has %d bits.\n", counter_bits);
|
---|
3097 | if (!counter_bits)
|
---|
3098 | gl_info->supported[ARB_OCCLUSION_QUERY] = FALSE;
|
---|
3099 | }
|
---|
3100 |
|
---|
3101 | wined3d_adapter_init_limits(gl_info);
|
---|
3102 |
|
---|
3103 | if (gl_info->supported[ARB_VERTEX_PROGRAM] && test_arb_vs_offset_limit(gl_info))
|
---|
3104 | gl_info->quirks |= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT;
|
---|
3105 |
|
---|
3106 | if (gl_info->supported[ARB_SHADING_LANGUAGE_100])
|
---|
3107 | {
|
---|
3108 | const char *str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
|
---|
3109 | unsigned int major, minor;
|
---|
3110 |
|
---|
3111 | TRACE("GLSL version string: %s.\n", debugstr_a(str));
|
---|
3112 |
|
---|
3113 | /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
|
---|
3114 | sscanf(str, "%u.%u", &major, &minor);
|
---|
3115 | gl_info->glsl_version = MAKEDWORD_VERSION(major, minor);
|
---|
3116 | }
|
---|
3117 |
|
---|
3118 | checkGLcall("extension detection");
|
---|
3119 |
|
---|
3120 | adapter->shader_backend = select_shader_backend(gl_info);
|
---|
3121 | adapter->vertex_pipe = select_vertex_implementation(gl_info, adapter->shader_backend);
|
---|
3122 | adapter->fragment_pipe = select_fragment_implementation(gl_info, adapter->shader_backend);
|
---|
3123 | adapter->blitter = select_blit_implementation(gl_info, adapter->shader_backend);
|
---|
3124 |
|
---|
3125 | adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
|
---|
3126 | adapter->d3d_info.vs_clipping = shader_caps.wined3d_caps & WINED3D_SHADER_CAP_VS_CLIPPING;
|
---|
3127 | adapter->d3d_info.limits.vs_version = shader_caps.vs_version;
|
---|
3128 | adapter->d3d_info.limits.gs_version = shader_caps.gs_version;
|
---|
3129 | adapter->d3d_info.limits.ps_version = shader_caps.ps_version;
|
---|
3130 | adapter->d3d_info.limits.vs_uniform_count = shader_caps.vs_uniform_count;
|
---|
3131 | adapter->d3d_info.limits.ps_uniform_count = shader_caps.ps_uniform_count;
|
---|
3132 |
|
---|
3133 | adapter->vertex_pipe->vp_get_caps(gl_info, &vertex_caps);
|
---|
3134 | adapter->d3d_info.xyzrhw = vertex_caps.xyzrhw;
|
---|
3135 |
|
---|
3136 | adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
|
---|
3137 | adapter->d3d_info.limits.ffp_blend_stages = fragment_caps.MaxTextureBlendStages;
|
---|
3138 | adapter->d3d_info.limits.ffp_textures = fragment_caps.MaxSimultaneousTextures;
|
---|
3139 | TRACE("Max texture stages: %u.\n", adapter->d3d_info.limits.ffp_blend_stages);
|
---|
3140 |
|
---|
3141 | if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
|
---|
3142 | {
|
---|
3143 | gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbuffer;
|
---|
3144 | gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbuffer;
|
---|
3145 | gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffers;
|
---|
3146 | gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffers;
|
---|
3147 | gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorage;
|
---|
3148 | gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisample;
|
---|
3149 | gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameteriv;
|
---|
3150 | gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebuffer;
|
---|
3151 | gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebuffer;
|
---|
3152 | gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffers;
|
---|
3153 | gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffers;
|
---|
3154 | gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatus;
|
---|
3155 | gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1D;
|
---|
3156 | gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2D;
|
---|
3157 | gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3D;
|
---|
3158 | gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbuffer;
|
---|
3159 | gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
|
---|
3160 | = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameteriv;
|
---|
3161 | gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebuffer;
|
---|
3162 | gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmap;
|
---|
3163 | }
|
---|
3164 | else
|
---|
3165 | {
|
---|
3166 | if (gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
|
---|
3167 | {
|
---|
3168 | gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbufferEXT;
|
---|
3169 | gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbufferEXT;
|
---|
3170 | gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffersEXT;
|
---|
3171 | gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffersEXT;
|
---|
3172 | gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorageEXT;
|
---|
3173 | gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameterivEXT;
|
---|
3174 | gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebufferEXT;
|
---|
3175 | gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebufferEXT;
|
---|
3176 | gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffersEXT;
|
---|
3177 | gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffersEXT;
|
---|
3178 | gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatusEXT;
|
---|
3179 | gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1DEXT;
|
---|
3180 | gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2DEXT;
|
---|
3181 | gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3DEXT;
|
---|
3182 | gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbufferEXT;
|
---|
3183 | gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
|
---|
3184 | = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameterivEXT;
|
---|
3185 | gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmapEXT;
|
---|
3186 | }
|
---|
3187 | else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
|
---|
3188 | {
|
---|
3189 | WARN_(d3d_perf)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
|
---|
3190 | wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
|
---|
3191 | }
|
---|
3192 | if (gl_info->supported[EXT_FRAMEBUFFER_BLIT])
|
---|
3193 | {
|
---|
3194 | gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebufferEXT;
|
---|
3195 | }
|
---|
3196 | if (gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
|
---|
3197 | {
|
---|
3198 | gl_info->fbo_ops.glRenderbufferStorageMultisample
|
---|
3199 | = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisampleEXT;
|
---|
3200 | }
|
---|
3201 | }
|
---|
3202 |
|
---|
3203 | gl_vendor = wined3d_guess_gl_vendor(gl_info, gl_vendor_str, gl_renderer_str);
|
---|
3204 | card_vendor = wined3d_guess_card_vendor(gl_vendor_str, gl_renderer_str);
|
---|
3205 | TRACE("Found GL_VENDOR (%s)->(0x%04x/0x%04x).\n", debugstr_a(gl_vendor_str), gl_vendor, card_vendor);
|
---|
3206 |
|
---|
3207 | device = wined3d_guess_card(gl_info, gl_renderer_str, &gl_vendor, &card_vendor);
|
---|
3208 | TRACE("Found (fake) card: 0x%x (vendor id), 0x%x (device id).\n", card_vendor, device);
|
---|
3209 |
|
---|
3210 | gl_info->wrap_lookup[WINED3D_TADDRESS_WRAP - WINED3D_TADDRESS_WRAP] = GL_REPEAT;
|
---|
3211 | gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR - WINED3D_TADDRESS_WRAP] =
|
---|
3212 | gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
|
---|
3213 | gl_info->wrap_lookup[WINED3D_TADDRESS_CLAMP - WINED3D_TADDRESS_WRAP] = GL_CLAMP_TO_EDGE;
|
---|
3214 | gl_info->wrap_lookup[WINED3D_TADDRESS_BORDER - WINED3D_TADDRESS_WRAP] =
|
---|
3215 | gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
|
---|
3216 | gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP] =
|
---|
3217 | gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] ? GL_MIRROR_CLAMP_TO_EDGE_ATI : GL_REPEAT;
|
---|
3218 |
|
---|
3219 | adapter->d3d_info.valid_rt_mask = 0;
|
---|
3220 | for (i = 0; i < gl_info->limits.buffers; ++i)
|
---|
3221 | adapter->d3d_info.valid_rt_mask |= (1 << i);
|
---|
3222 |
|
---|
3223 | fixup_extensions(gl_info, gl_renderer_str, gl_vendor, card_vendor, device);
|
---|
3224 | init_driver_info(driver_info, card_vendor, device);
|
---|
3225 | add_gl_compat_wrappers(gl_info);
|
---|
3226 |
|
---|
3227 | return TRUE;
|
---|
3228 | }
|
---|
3229 |
|
---|
3230 | UINT CDECL wined3d_get_adapter_count(const struct wined3d *wined3d)
|
---|
3231 | {
|
---|
3232 | TRACE("wined3d %p, reporting %u adapters.\n",
|
---|
3233 | wined3d, wined3d->adapter_count);
|
---|
3234 |
|
---|
3235 | return wined3d->adapter_count;
|
---|
3236 | }
|
---|
3237 |
|
---|
3238 | HRESULT CDECL wined3d_register_software_device(struct wined3d *wined3d, void *init_function)
|
---|
3239 | {
|
---|
3240 | FIXME("wined3d %p, init_function %p stub!\n", wined3d, init_function);
|
---|
3241 |
|
---|
3242 | return WINED3D_OK;
|
---|
3243 | }
|
---|
3244 |
|
---|
3245 | HMONITOR CDECL wined3d_get_adapter_monitor(const struct wined3d *wined3d, UINT adapter_idx)
|
---|
3246 | {
|
---|
3247 | TRACE("wined3d %p, adapter_idx %u.\n", wined3d, adapter_idx);
|
---|
3248 |
|
---|
3249 | if (adapter_idx >= wined3d->adapter_count)
|
---|
3250 | return NULL;
|
---|
3251 |
|
---|
3252 | return MonitorFromPoint(wined3d->adapters[adapter_idx].monitorPoint, MONITOR_DEFAULTTOPRIMARY);
|
---|
3253 | }
|
---|
3254 |
|
---|
3255 | /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
|
---|
3256 | of the same bpp but different resolutions */
|
---|
3257 |
|
---|
3258 | /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
|
---|
3259 | UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT adapter_idx,
|
---|
3260 | enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering)
|
---|
3261 | {
|
---|
3262 | const struct wined3d_adapter *adapter;
|
---|
3263 | const struct wined3d_format *format;
|
---|
3264 | unsigned int i = 0;
|
---|
3265 | unsigned int j = 0;
|
---|
3266 | UINT format_bits;
|
---|
3267 | DEVMODEW mode;
|
---|
3268 |
|
---|
3269 | TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x.\n",
|
---|
3270 | wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering);
|
---|
3271 |
|
---|
3272 | if (adapter_idx >= wined3d->adapter_count)
|
---|
3273 | return 0;
|
---|
3274 |
|
---|
3275 | adapter = &wined3d->adapters[adapter_idx];
|
---|
3276 | format = wined3d_get_format(&adapter->gl_info, format_id);
|
---|
3277 | format_bits = format->byte_count * CHAR_BIT;
|
---|
3278 |
|
---|
3279 | memset(&mode, 0, sizeof(mode));
|
---|
3280 | mode.dmSize = sizeof(mode);
|
---|
3281 |
|
---|
3282 | while (EnumDisplaySettingsExW(adapter->DeviceName, j++, &mode, 0))
|
---|
3283 | {
|
---|
3284 | if (mode.dmFields & DM_DISPLAYFLAGS)
|
---|
3285 | {
|
---|
3286 | if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
|
---|
3287 | #ifndef VBOX_WINE_WITHOUT_LIBWINE
|
---|
3288 | && (mode.u2.dmDisplayFlags & DM_INTERLACED))
|
---|
3289 | #else
|
---|
3290 | && (mode.dmDisplayFlags & DM_INTERLACED))
|
---|
3291 | #endif
|
---|
3292 | continue;
|
---|
3293 |
|
---|
3294 | if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
|
---|
3295 | #ifndef VBOX_WINE_WITHOUT_LIBWINE
|
---|
3296 | && !(mode.u2.dmDisplayFlags & DM_INTERLACED))
|
---|
3297 | #else
|
---|
3298 | && !(mode.dmDisplayFlags & DM_INTERLACED))
|
---|
3299 | #endif
|
---|
3300 | continue;
|
---|
3301 | }
|
---|
3302 |
|
---|
3303 | if (format_id == WINED3DFMT_UNKNOWN)
|
---|
3304 | {
|
---|
3305 | /* This is for d3d8, do not enumerate P8 here. */
|
---|
3306 | if (mode.dmBitsPerPel == 32 || mode.dmBitsPerPel == 16) ++i;
|
---|
3307 | }
|
---|
3308 | else if (mode.dmBitsPerPel == format_bits)
|
---|
3309 | {
|
---|
3310 | ++i;
|
---|
3311 | }
|
---|
3312 | }
|
---|
3313 |
|
---|
3314 | TRACE("Returning %u matching modes (out of %u total) for adapter %u.\n", i, j, adapter_idx);
|
---|
3315 |
|
---|
3316 | return i;
|
---|
3317 | }
|
---|
3318 |
|
---|
3319 | /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
|
---|
3320 | HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT adapter_idx,
|
---|
3321 | enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering,
|
---|
3322 | UINT mode_idx, struct wined3d_display_mode *mode)
|
---|
3323 | {
|
---|
3324 | const struct wined3d_adapter *adapter;
|
---|
3325 | const struct wined3d_format *format;
|
---|
3326 | UINT format_bits;
|
---|
3327 | DEVMODEW m;
|
---|
3328 | UINT i = 0;
|
---|
3329 | int j = 0;
|
---|
3330 |
|
---|
3331 | TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x, mode_idx %u, mode %p.\n",
|
---|
3332 | wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering, mode_idx, mode);
|
---|
3333 |
|
---|
3334 | if (!mode || adapter_idx >= wined3d->adapter_count)
|
---|
3335 | return WINED3DERR_INVALIDCALL;
|
---|
3336 |
|
---|
3337 | adapter = &wined3d->adapters[adapter_idx];
|
---|
3338 | format = wined3d_get_format(&adapter->gl_info, format_id);
|
---|
3339 | format_bits = format->byte_count * CHAR_BIT;
|
---|
3340 |
|
---|
3341 | memset(&m, 0, sizeof(m));
|
---|
3342 | m.dmSize = sizeof(m);
|
---|
3343 |
|
---|
3344 | while (i <= mode_idx)
|
---|
3345 | {
|
---|
3346 | if (!EnumDisplaySettingsExW(adapter->DeviceName, j++, &m, 0))
|
---|
3347 | {
|
---|
3348 | WARN("Invalid mode_idx %u.\n", mode_idx);
|
---|
3349 | return WINED3DERR_INVALIDCALL;
|
---|
3350 | }
|
---|
3351 |
|
---|
3352 | if (m.dmFields & DM_DISPLAYFLAGS)
|
---|
3353 | {
|
---|
3354 | if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
|
---|
3355 | #ifndef VBOX_WINE_WITHOUT_LIBWINE
|
---|
3356 | && (m.u2.dmDisplayFlags & DM_INTERLACED))
|
---|
3357 | #else
|
---|
3358 | && (m.dmDisplayFlags & DM_INTERLACED))
|
---|
3359 | #endif
|
---|
3360 | continue;
|
---|
3361 |
|
---|
3362 | if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
|
---|
3363 | #ifndef VBOX_WINE_WITHOUT_LIBWINE
|
---|
3364 | && !(m.u2.dmDisplayFlags & DM_INTERLACED))
|
---|
3365 | #else
|
---|
3366 | && !(m.dmDisplayFlags & DM_INTERLACED))
|
---|
3367 | #endif
|
---|
3368 | continue;
|
---|
3369 | }
|
---|
3370 |
|
---|
3371 | if (format_id == WINED3DFMT_UNKNOWN)
|
---|
3372 | {
|
---|
3373 | /* This is for d3d8, do not enumerate P8 here. */
|
---|
3374 | if (m.dmBitsPerPel == 32 || m.dmBitsPerPel == 16) ++i;
|
---|
3375 | }
|
---|
3376 | else if (m.dmBitsPerPel == format_bits)
|
---|
3377 | {
|
---|
3378 | ++i;
|
---|
3379 | }
|
---|
3380 | }
|
---|
3381 |
|
---|
3382 | mode->width = m.dmPelsWidth;
|
---|
3383 | mode->height = m.dmPelsHeight;
|
---|
3384 | mode->refresh_rate = DEFAULT_REFRESH_RATE;
|
---|
3385 | if (m.dmFields & DM_DISPLAYFREQUENCY)
|
---|
3386 | mode->refresh_rate = m.dmDisplayFrequency;
|
---|
3387 |
|
---|
3388 | if (format_id == WINED3DFMT_UNKNOWN)
|
---|
3389 | mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
|
---|
3390 | else
|
---|
3391 | mode->format_id = format_id;
|
---|
3392 |
|
---|
3393 | if (!(m.dmFields & DM_DISPLAYFLAGS))
|
---|
3394 | mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
|
---|
3395 | #ifndef VBOX_WINE_WITHOUT_LIBWINE
|
---|
3396 | else if (m.u2.dmDisplayFlags & DM_INTERLACED)
|
---|
3397 | #else
|
---|
3398 | else if (m.dmDisplayFlags & DM_INTERLACED)
|
---|
3399 | #endif
|
---|
3400 | mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
|
---|
3401 | else
|
---|
3402 | mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
|
---|
3403 |
|
---|
3404 | TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
|
---|
3405 | m.dmBitsPerPel, debug_d3dformat(mode->format_id), mode->scanline_ordering);
|
---|
3406 |
|
---|
3407 | return WINED3D_OK;
|
---|
3408 | }
|
---|
3409 |
|
---|
3410 | HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx,
|
---|
3411 | struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
|
---|
3412 | {
|
---|
3413 | const struct wined3d_adapter *adapter;
|
---|
3414 | DEVMODEW m;
|
---|
3415 |
|
---|
3416 | TRACE("wined3d %p, adapter_idx %u, display_mode %p, rotation %p.\n",
|
---|
3417 | wined3d, adapter_idx, mode, rotation);
|
---|
3418 |
|
---|
3419 | if (!mode || adapter_idx >= wined3d->adapter_count)
|
---|
3420 | return WINED3DERR_INVALIDCALL;
|
---|
3421 |
|
---|
3422 | adapter = &wined3d->adapters[adapter_idx];
|
---|
3423 |
|
---|
3424 | memset(&m, 0, sizeof(m));
|
---|
3425 | m.dmSize = sizeof(m);
|
---|
3426 |
|
---|
3427 | EnumDisplaySettingsExW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &m, 0);
|
---|
3428 | mode->width = m.dmPelsWidth;
|
---|
3429 | mode->height = m.dmPelsHeight;
|
---|
3430 | mode->refresh_rate = DEFAULT_REFRESH_RATE;
|
---|
3431 | if (m.dmFields & DM_DISPLAYFREQUENCY)
|
---|
3432 | mode->refresh_rate = m.dmDisplayFrequency;
|
---|
3433 | mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
|
---|
3434 |
|
---|
3435 | /* Lie about the format. X11 can't change the color depth, and some apps
|
---|
3436 | * are pretty angry if they SetDisplayMode from 24 to 16 bpp and find out
|
---|
3437 | * that GetDisplayMode still returns 24 bpp. This should probably be
|
---|
3438 | * handled in winex11 instead. */
|
---|
3439 | if (adapter->screen_format && adapter->screen_format != mode->format_id)
|
---|
3440 | {
|
---|
3441 | WARN("Overriding format %s with stored format %s.\n",
|
---|
3442 | debug_d3dformat(mode->format_id),
|
---|
3443 | debug_d3dformat(adapter->screen_format));
|
---|
3444 | mode->format_id = adapter->screen_format;
|
---|
3445 | }
|
---|
3446 |
|
---|
3447 | if (!(m.dmFields & DM_DISPLAYFLAGS))
|
---|
3448 | mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
|
---|
3449 | #ifndef VBOX_WINE_WITHOUT_LIBWINE
|
---|
3450 | else if (m.u2.dmDisplayFlags & DM_INTERLACED)
|
---|
3451 | #else
|
---|
3452 | else if (m.dmDisplayFlags & DM_INTERLACED)
|
---|
3453 | #endif
|
---|
3454 | mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
|
---|
3455 | else
|
---|
3456 | mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
|
---|
3457 |
|
---|
3458 | if (rotation)
|
---|
3459 | {
|
---|
3460 | #ifndef VBOX_WINE_WITHOUT_LIBWINE
|
---|
3461 | switch (m.u1.s2.dmDisplayOrientation)
|
---|
3462 | #else
|
---|
3463 | switch (m.dmDisplayOrientation)
|
---|
3464 | #endif
|
---|
3465 | {
|
---|
3466 | case DMDO_DEFAULT:
|
---|
3467 | *rotation = WINED3D_DISPLAY_ROTATION_0;
|
---|
3468 | break;
|
---|
3469 | case DMDO_90:
|
---|
3470 | *rotation = WINED3D_DISPLAY_ROTATION_90;
|
---|
3471 | break;
|
---|
3472 | case DMDO_180:
|
---|
3473 | *rotation = WINED3D_DISPLAY_ROTATION_180;
|
---|
3474 | break;
|
---|
3475 | case DMDO_270:
|
---|
3476 | *rotation = WINED3D_DISPLAY_ROTATION_270;
|
---|
3477 | break;
|
---|
3478 | default:
|
---|
3479 | #ifndef VBOX_WINE_WITHOUT_LIBWINE
|
---|
3480 | FIXME("Unhandled display rotation %#x.\n", m.u1.s2.dmDisplayOrientation);
|
---|
3481 | #else
|
---|
3482 | FIXME("Unhandled display rotation %#x.\n", m.dmDisplayOrientation);
|
---|
3483 | #endif
|
---|
3484 | *rotation = WINED3D_DISPLAY_ROTATION_UNSPECIFIED;
|
---|
3485 | break;
|
---|
3486 | }
|
---|
3487 | }
|
---|
3488 |
|
---|
3489 | TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
|
---|
3490 | mode->refresh_rate, debug_d3dformat(mode->format_id),
|
---|
3491 | mode->scanline_ordering);
|
---|
3492 | return WINED3D_OK;
|
---|
3493 | }
|
---|
3494 |
|
---|
3495 | HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d,
|
---|
3496 | UINT adapter_idx, const struct wined3d_display_mode *mode)
|
---|
3497 | {
|
---|
3498 | struct wined3d_display_mode current_mode;
|
---|
3499 | const struct wined3d_format *format;
|
---|
3500 | struct wined3d_adapter *adapter;
|
---|
3501 | DEVMODEW devmode;
|
---|
3502 | RECT clip_rc;
|
---|
3503 | HRESULT hr;
|
---|
3504 | LONG ret;
|
---|
3505 |
|
---|
3506 | TRACE("wined3d %p, adapter_idx %u, mode %p (%ux%u@%u %s %#x).\n", wined3d, adapter_idx, mode,
|
---|
3507 | mode->width, mode->height, mode->refresh_rate, debug_d3dformat(mode->format_id),
|
---|
3508 | mode->scanline_ordering);
|
---|
3509 |
|
---|
3510 | if (adapter_idx >= wined3d->adapter_count)
|
---|
3511 | return WINED3DERR_INVALIDCALL;
|
---|
3512 |
|
---|
3513 | adapter = &wined3d->adapters[adapter_idx];
|
---|
3514 | format = wined3d_get_format(&adapter->gl_info, mode->format_id);
|
---|
3515 |
|
---|
3516 | memset(&devmode, 0, sizeof(devmode));
|
---|
3517 | devmode.dmSize = sizeof(devmode);
|
---|
3518 | devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
---|
3519 | devmode.dmBitsPerPel = format->byte_count * CHAR_BIT;
|
---|
3520 | devmode.dmPelsWidth = mode->width;
|
---|
3521 | devmode.dmPelsHeight = mode->height;
|
---|
3522 |
|
---|
3523 | devmode.dmDisplayFrequency = mode->refresh_rate;
|
---|
3524 | if (mode->refresh_rate)
|
---|
3525 | devmode.dmFields |= DM_DISPLAYFREQUENCY;
|
---|
3526 |
|
---|
3527 | if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
|
---|
3528 | {
|
---|
3529 | devmode.dmFields |= DM_DISPLAYFLAGS;
|
---|
3530 | if (mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED)
|
---|
3531 | #ifndef VBOX_WINE_WITHOUT_LIBWINE
|
---|
3532 | devmode.u2.dmDisplayFlags |= DM_INTERLACED;
|
---|
3533 | #else
|
---|
3534 | devmode.dmDisplayFlags |= DM_INTERLACED;
|
---|
3535 | #endif
|
---|
3536 | }
|
---|
3537 |
|
---|
3538 | /* Only change the mode if necessary. */
|
---|
3539 | if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx, ¤t_mode, NULL)))
|
---|
3540 | {
|
---|
3541 | ERR("Failed to get current display mode, hr %#x.\n", hr);
|
---|
3542 | }
|
---|
3543 | else if (current_mode.width == mode->width
|
---|
3544 | && current_mode.height == mode->height
|
---|
3545 | && current_mode.format_id == mode->format_id
|
---|
3546 | && (current_mode.refresh_rate == mode->refresh_rate
|
---|
3547 | || !mode->refresh_rate)
|
---|
3548 | && (current_mode.scanline_ordering == mode->scanline_ordering
|
---|
3549 | || mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_UNKNOWN))
|
---|
3550 | {
|
---|
3551 | TRACE("Skipping redundant mode setting call.\n");
|
---|
3552 | return WINED3D_OK;
|
---|
3553 | }
|
---|
3554 |
|
---|
3555 | ret = ChangeDisplaySettingsExW(adapter->DeviceName, &devmode, NULL, CDS_FULLSCREEN, NULL);
|
---|
3556 | if (ret != DISP_CHANGE_SUCCESSFUL)
|
---|
3557 | {
|
---|
3558 | if (devmode.dmDisplayFrequency)
|
---|
3559 | {
|
---|
3560 | WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate.\n");
|
---|
3561 | devmode.dmFields &= ~DM_DISPLAYFREQUENCY;
|
---|
3562 | devmode.dmDisplayFrequency = 0;
|
---|
3563 | ret = ChangeDisplaySettingsExW(adapter->DeviceName, &devmode, NULL, CDS_FULLSCREEN, NULL);
|
---|
3564 | }
|
---|
3565 | if (ret != DISP_CHANGE_SUCCESSFUL)
|
---|
3566 | return WINED3DERR_NOTAVAILABLE;
|
---|
3567 | }
|
---|
3568 |
|
---|
3569 | /* Store the new values. */
|
---|
3570 | adapter->screen_format = mode->format_id;
|
---|
3571 |
|
---|
3572 | /* And finally clip mouse to our screen. */
|
---|
3573 | SetRect(&clip_rc, 0, 0, mode->width, mode->height);
|
---|
3574 | ClipCursor(&clip_rc);
|
---|
3575 |
|
---|
3576 | return WINED3D_OK;
|
---|
3577 | }
|
---|
3578 |
|
---|
3579 | /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
|
---|
3580 | and fields being inserted in the middle, a new structure is used in place */
|
---|
3581 | HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d,
|
---|
3582 | UINT adapter_idx, DWORD flags, struct wined3d_adapter_identifier *identifier)
|
---|
3583 | {
|
---|
3584 | #ifndef VBOX_WITH_WDDM
|
---|
3585 | const struct wined3d_adapter *adapter;
|
---|
3586 | size_t len;
|
---|
3587 |
|
---|
3588 | TRACE("wined3d %p, adapter_idx %u, flags %#x, identifier %p.\n",
|
---|
3589 | wined3d, adapter_idx, flags, identifier);
|
---|
3590 |
|
---|
3591 | if (adapter_idx >= wined3d->adapter_count)
|
---|
3592 | return WINED3DERR_INVALIDCALL;
|
---|
3593 |
|
---|
3594 | adapter = &wined3d->adapters[adapter_idx];
|
---|
3595 |
|
---|
3596 | if (identifier->driver_size)
|
---|
3597 | {
|
---|
3598 | const char *name = adapter->driver_info.name;
|
---|
3599 | len = min(strlen(name), identifier->driver_size - 1);
|
---|
3600 | memcpy(identifier->driver, name, len);
|
---|
3601 | identifier->driver[len] = '\0';
|
---|
3602 | }
|
---|
3603 |
|
---|
3604 | if (identifier->description_size)
|
---|
3605 | {
|
---|
3606 | const char *description = adapter->driver_info.description;
|
---|
3607 | len = min(strlen(description), identifier->description_size - 1);
|
---|
3608 | memcpy(identifier->description, description, len);
|
---|
3609 | identifier->description[len] = '\0';
|
---|
3610 | }
|
---|
3611 |
|
---|
3612 | /* Note that d3d8 doesn't supply a device name. */
|
---|
3613 | if (identifier->device_name_size)
|
---|
3614 | {
|
---|
3615 | if (!WideCharToMultiByte(CP_ACP, 0, adapter->DeviceName, -1, identifier->device_name,
|
---|
3616 | identifier->device_name_size, NULL, NULL))
|
---|
3617 | {
|
---|
3618 | ERR("Failed to convert device name, last error %#x.\n", GetLastError());
|
---|
3619 | return WINED3DERR_INVALIDCALL;
|
---|
3620 | }
|
---|
3621 | }
|
---|
3622 |
|
---|
3623 | identifier->driver_version.u.HighPart = adapter->driver_info.version_high;
|
---|
3624 | identifier->driver_version.u.LowPart = adapter->driver_info.version_low;
|
---|
3625 | identifier->vendor_id = adapter->driver_info.vendor;
|
---|
3626 | identifier->device_id = adapter->driver_info.device;
|
---|
3627 | identifier->subsystem_id = 0;
|
---|
3628 | identifier->revision = 0;
|
---|
3629 | memcpy(&identifier->device_identifier, &IID_D3DDEVICE_D3DUID, sizeof(identifier->device_identifier));
|
---|
3630 | identifier->whql_level = (flags & WINED3DENUM_NO_WHQL_LEVEL) ? 0 : 1;
|
---|
3631 | memcpy(&identifier->adapter_luid, &adapter->luid, sizeof(identifier->adapter_luid));
|
---|
3632 | identifier->video_memory = adapter->TextureRam;
|
---|
3633 |
|
---|
3634 | return WINED3D_OK;
|
---|
3635 | #else
|
---|
3636 | ERR("not supported!");
|
---|
3637 | return E_FAIL;
|
---|
3638 | #endif
|
---|
3639 | }
|
---|
3640 |
|
---|
3641 | HRESULT CDECL wined3d_get_adapter_raster_status(const struct wined3d *wined3d, UINT adapter_idx,
|
---|
3642 | struct wined3d_raster_status *raster_status)
|
---|
3643 | {
|
---|
3644 | LONGLONG freq_per_frame, freq_per_line;
|
---|
3645 | LARGE_INTEGER counter, freq_per_sec;
|
---|
3646 | struct wined3d_display_mode mode;
|
---|
3647 | static UINT once;
|
---|
3648 |
|
---|
3649 | if (!once++)
|
---|
3650 | FIXME("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
|
---|
3651 | wined3d, adapter_idx, raster_status);
|
---|
3652 | else
|
---|
3653 | WARN("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
|
---|
3654 | wined3d, adapter_idx, raster_status);
|
---|
3655 |
|
---|
3656 | /* Obtaining the raster status is a widely implemented but optional
|
---|
3657 | * feature. When this method returns OK StarCraft 2 expects the
|
---|
3658 | * raster_status->InVBlank value to actually change over time.
|
---|
3659 | * And Endless Alice Crysis doesn't care even if this method fails.
|
---|
3660 | * Thus this method returns OK and fakes raster_status by
|
---|
3661 | * QueryPerformanceCounter. */
|
---|
3662 |
|
---|
3663 | if (!QueryPerformanceCounter(&counter) || !QueryPerformanceFrequency(&freq_per_sec))
|
---|
3664 | return WINED3DERR_INVALIDCALL;
|
---|
3665 | if (FAILED(wined3d_get_adapter_display_mode(wined3d, adapter_idx, &mode, NULL)))
|
---|
3666 | return WINED3DERR_INVALIDCALL;
|
---|
3667 | if (mode.refresh_rate == DEFAULT_REFRESH_RATE)
|
---|
3668 | mode.refresh_rate = 60;
|
---|
3669 |
|
---|
3670 | freq_per_frame = freq_per_sec.QuadPart / mode.refresh_rate;
|
---|
3671 | /* Assume 20 scan lines in the vertical blank. */
|
---|
3672 | freq_per_line = freq_per_frame / (mode.height + 20);
|
---|
3673 | raster_status->scan_line = (counter.QuadPart % freq_per_frame) / freq_per_line;
|
---|
3674 | if (raster_status->scan_line < mode.height)
|
---|
3675 | raster_status->in_vblank = FALSE;
|
---|
3676 | else
|
---|
3677 | {
|
---|
3678 | raster_status->scan_line = 0;
|
---|
3679 | raster_status->in_vblank = TRUE;
|
---|
3680 | }
|
---|
3681 |
|
---|
3682 | TRACE("Returning fake value, in_vblank %u, scan_line %u.\n",
|
---|
3683 | raster_status->in_vblank, raster_status->scan_line);
|
---|
3684 |
|
---|
3685 | return WINED3D_OK;
|
---|
3686 | }
|
---|
3687 |
|
---|
3688 | static BOOL wined3d_check_pixel_format_color(const struct wined3d_gl_info *gl_info,
|
---|
3689 | const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
|
---|
3690 | {
|
---|
3691 | BYTE redSize, greenSize, blueSize, alphaSize, colorBits;
|
---|
3692 |
|
---|
3693 | /* Float formats need FBOs. If FBOs are used this function isn't called */
|
---|
3694 | if (format->flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
|
---|
3695 |
|
---|
3696 | if(cfg->iPixelType == WGL_TYPE_RGBA_ARB) { /* Integer RGBA formats */
|
---|
3697 | if (!getColorBits(format, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits))
|
---|
3698 | {
|
---|
3699 | ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format->id));
|
---|
3700 | return FALSE;
|
---|
3701 | }
|
---|
3702 |
|
---|
3703 | if(cfg->redSize < redSize)
|
---|
3704 | return FALSE;
|
---|
3705 |
|
---|
3706 | if(cfg->greenSize < greenSize)
|
---|
3707 | return FALSE;
|
---|
3708 |
|
---|
3709 | if(cfg->blueSize < blueSize)
|
---|
3710 | return FALSE;
|
---|
3711 |
|
---|
3712 | if(cfg->alphaSize < alphaSize)
|
---|
3713 | return FALSE;
|
---|
3714 |
|
---|
3715 | return TRUE;
|
---|
3716 | }
|
---|
3717 |
|
---|
3718 | /* Probably a RGBA_float or color index mode */
|
---|
3719 | return FALSE;
|
---|
3720 | }
|
---|
3721 |
|
---|
3722 | static BOOL wined3d_check_pixel_format_depth(const struct wined3d_gl_info *gl_info,
|
---|
3723 | const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
|
---|
3724 | {
|
---|
3725 | BYTE depthSize, stencilSize;
|
---|
3726 | BOOL lockable = FALSE;
|
---|
3727 |
|
---|
3728 | if (!getDepthStencilBits(format, &depthSize, &stencilSize))
|
---|
3729 | {
|
---|
3730 | ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format->id));
|
---|
3731 | return FALSE;
|
---|
3732 | }
|
---|
3733 |
|
---|
3734 | /* Float formats need FBOs. If FBOs are used this function isn't called */
|
---|
3735 | if (format->flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
|
---|
3736 |
|
---|
3737 | if ((format->id == WINED3DFMT_D16_LOCKABLE) || (format->id == WINED3DFMT_D32_FLOAT))
|
---|
3738 | lockable = TRUE;
|
---|
3739 |
|
---|
3740 | /* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports.
|
---|
3741 | * We can safely report 'compatible' formats (e.g. D24 can be used for D16) as long as we aren't dealing with
|
---|
3742 | * a lockable format. This also helps D3D <= 7 as they expect D16 which isn't offered without this on Geforce8 cards. */
|
---|
3743 | if(!(cfg->depthSize == depthSize || (!lockable && cfg->depthSize > depthSize)))
|
---|
3744 | return FALSE;
|
---|
3745 |
|
---|
3746 | /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
|
---|
3747 | * allow more stencil bits than requested. */
|
---|
3748 | if(cfg->stencilSize < stencilSize)
|
---|
3749 | return FALSE;
|
---|
3750 |
|
---|
3751 | return TRUE;
|
---|
3752 | }
|
---|
3753 |
|
---|
3754 | HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d *wined3d,
|
---|
3755 | UINT adapter_idx, enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id,
|
---|
3756 | enum wined3d_format_id render_target_format_id, enum wined3d_format_id depth_stencil_format_id)
|
---|
3757 | {
|
---|
3758 | const struct wined3d_format *rt_format;
|
---|
3759 | const struct wined3d_format *ds_format;
|
---|
3760 | const struct wined3d_adapter *adapter;
|
---|
3761 |
|
---|
3762 | TRACE("wined3d %p, adapter_idx %u, device_type %s,\n"
|
---|
3763 | "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
|
---|
3764 | wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
|
---|
3765 | debug_d3dformat(render_target_format_id), debug_d3dformat(depth_stencil_format_id));
|
---|
3766 |
|
---|
3767 | if (adapter_idx >= wined3d->adapter_count)
|
---|
3768 | return WINED3DERR_INVALIDCALL;
|
---|
3769 |
|
---|
3770 | adapter = &wined3d->adapters[adapter_idx];
|
---|
3771 | rt_format = wined3d_get_format(&adapter->gl_info, render_target_format_id);
|
---|
3772 | ds_format = wined3d_get_format(&adapter->gl_info, depth_stencil_format_id);
|
---|
3773 | if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
|
---|
3774 | {
|
---|
3775 | if ((rt_format->flags & WINED3DFMT_FLAG_RENDERTARGET)
|
---|
3776 | && (ds_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
|
---|
3777 | {
|
---|
3778 | TRACE("Formats match.\n");
|
---|
3779 | return WINED3D_OK;
|
---|
3780 | }
|
---|
3781 | }
|
---|
3782 | else
|
---|
3783 | {
|
---|
3784 | const struct wined3d_pixel_format *cfgs;
|
---|
3785 | unsigned int cfg_count;
|
---|
3786 | unsigned int i;
|
---|
3787 |
|
---|
3788 | cfgs = adapter->cfgs;
|
---|
3789 | cfg_count = adapter->cfg_count;
|
---|
3790 | for (i = 0; i < cfg_count; ++i)
|
---|
3791 | {
|
---|
3792 | if (wined3d_check_pixel_format_color(&adapter->gl_info, &cfgs[i], rt_format)
|
---|
3793 | && wined3d_check_pixel_format_depth(&adapter->gl_info, &cfgs[i], ds_format))
|
---|
3794 | {
|
---|
3795 | TRACE("Formats match.\n");
|
---|
3796 | return WINED3D_OK;
|
---|
3797 | }
|
---|
3798 | }
|
---|
3799 | }
|
---|
3800 |
|
---|
3801 | TRACE("Unsupported format pair: %s and %s.\n",
|
---|
3802 | debug_d3dformat(render_target_format_id),
|
---|
3803 | debug_d3dformat(depth_stencil_format_id));
|
---|
3804 |
|
---|
3805 | return WINED3DERR_NOTAVAILABLE;
|
---|
3806 | }
|
---|
3807 |
|
---|
3808 | HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3d, UINT adapter_idx,
|
---|
3809 | enum wined3d_device_type device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
|
---|
3810 | enum wined3d_multisample_type multisample_type, DWORD *quality_levels)
|
---|
3811 | {
|
---|
3812 | const struct wined3d_gl_info *gl_info;
|
---|
3813 |
|
---|
3814 | TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s,\n"
|
---|
3815 | "windowed %#x, multisample_type %#x, quality_levels %p.\n",
|
---|
3816 | wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(surface_format_id),
|
---|
3817 | windowed, multisample_type, quality_levels);
|
---|
3818 |
|
---|
3819 | if (adapter_idx >= wined3d->adapter_count)
|
---|
3820 | return WINED3DERR_INVALIDCALL;
|
---|
3821 |
|
---|
3822 | gl_info = &wined3d->adapters[adapter_idx].gl_info;
|
---|
3823 |
|
---|
3824 | if (multisample_type > gl_info->limits.samples)
|
---|
3825 | {
|
---|
3826 | TRACE("Returning not supported.\n");
|
---|
3827 | if (quality_levels)
|
---|
3828 | *quality_levels = 0;
|
---|
3829 |
|
---|
3830 | return WINED3DERR_NOTAVAILABLE;
|
---|
3831 | }
|
---|
3832 |
|
---|
3833 | if (quality_levels)
|
---|
3834 | {
|
---|
3835 | if (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE)
|
---|
3836 | /* FIXME: This is probably wrong. */
|
---|
3837 | *quality_levels = gl_info->limits.samples;
|
---|
3838 | else
|
---|
3839 | *quality_levels = 1;
|
---|
3840 | }
|
---|
3841 |
|
---|
3842 | return WINED3D_OK;
|
---|
3843 | }
|
---|
3844 |
|
---|
3845 | /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
|
---|
3846 | static BOOL CheckDepthStencilCapability(const struct wined3d_adapter *adapter,
|
---|
3847 | const struct wined3d_format *display_format, const struct wined3d_format *ds_format)
|
---|
3848 | {
|
---|
3849 | /* Only allow depth/stencil formats */
|
---|
3850 | if (!(ds_format->depth_size || ds_format->stencil_size)) return FALSE;
|
---|
3851 |
|
---|
3852 | /* Blacklist formats not supported on Windows */
|
---|
3853 | switch (ds_format->id)
|
---|
3854 | {
|
---|
3855 | case WINED3DFMT_S1_UINT_D15_UNORM: /* Breaks the shadowvol2 dx7 sdk sample */
|
---|
3856 | case WINED3DFMT_S4X4_UINT_D24_UNORM:
|
---|
3857 | TRACE("[FAILED] - not supported on windows.\n");
|
---|
3858 | return FALSE;
|
---|
3859 |
|
---|
3860 | default:
|
---|
3861 | break;
|
---|
3862 | }
|
---|
3863 |
|
---|
3864 | if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
|
---|
3865 | {
|
---|
3866 | /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
|
---|
3867 | if (ds_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) return TRUE;
|
---|
3868 | }
|
---|
3869 | else
|
---|
3870 | {
|
---|
3871 | unsigned int i;
|
---|
3872 |
|
---|
3873 | /* Walk through all WGL pixel formats to find a match */
|
---|
3874 | for (i = 0; i < adapter->cfg_count; ++i)
|
---|
3875 | {
|
---|
3876 | const struct wined3d_pixel_format *cfg = &adapter->cfgs[i];
|
---|
3877 | if (wined3d_check_pixel_format_color(&adapter->gl_info, cfg, display_format)
|
---|
3878 | && wined3d_check_pixel_format_depth(&adapter->gl_info, cfg, ds_format))
|
---|
3879 | return TRUE;
|
---|
3880 | }
|
---|
3881 | }
|
---|
3882 |
|
---|
3883 | return FALSE;
|
---|
3884 | }
|
---|
3885 |
|
---|
3886 | /* Check the render target capabilities of a format */
|
---|
3887 | static BOOL CheckRenderTargetCapability(const struct wined3d_adapter *adapter,
|
---|
3888 | const struct wined3d_format *adapter_format, const struct wined3d_format *check_format)
|
---|
3889 | {
|
---|
3890 | /* Filter out non-RT formats */
|
---|
3891 | if (!(check_format->flags & WINED3DFMT_FLAG_RENDERTARGET)) return FALSE;
|
---|
3892 | if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
|
---|
3893 | {
|
---|
3894 | BYTE AdapterRed, AdapterGreen, AdapterBlue, AdapterAlpha, AdapterTotalSize;
|
---|
3895 | BYTE CheckRed, CheckGreen, CheckBlue, CheckAlpha, CheckTotalSize;
|
---|
3896 | const struct wined3d_pixel_format *cfgs = adapter->cfgs;
|
---|
3897 | unsigned int i;
|
---|
3898 |
|
---|
3899 | getColorBits(adapter_format, &AdapterRed, &AdapterGreen, &AdapterBlue, &AdapterAlpha, &AdapterTotalSize);
|
---|
3900 | getColorBits(check_format, &CheckRed, &CheckGreen, &CheckBlue, &CheckAlpha, &CheckTotalSize);
|
---|
3901 |
|
---|
3902 | /* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
|
---|
3903 | * The format must match in RGB, alpha is allowed to be different. (Only the backbuffer can have alpha) */
|
---|
3904 | if (!((AdapterRed == CheckRed) && (AdapterGreen == CheckGreen) && (AdapterBlue == CheckBlue)))
|
---|
3905 | {
|
---|
3906 | TRACE("[FAILED]\n");
|
---|
3907 | return FALSE;
|
---|
3908 | }
|
---|
3909 |
|
---|
3910 | /* Check if there is a WGL pixel format matching the requirements, the format should also be window
|
---|
3911 | * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
|
---|
3912 | for (i = 0; i < adapter->cfg_count; ++i)
|
---|
3913 | {
|
---|
3914 | if (cfgs[i].windowDrawable
|
---|
3915 | && wined3d_check_pixel_format_color(&adapter->gl_info, &cfgs[i], check_format))
|
---|
3916 | {
|
---|
3917 | TRACE("Pixel format %d is compatible with format %s.\n",
|
---|
3918 | cfgs[i].iPixelFormat, debug_d3dformat(check_format->id));
|
---|
3919 | return TRUE;
|
---|
3920 | }
|
---|
3921 | }
|
---|
3922 | }
|
---|
3923 | else if(wined3d_settings.offscreen_rendering_mode == ORM_FBO)
|
---|
3924 | {
|
---|
3925 | /* For now return TRUE for FBOs until we have some proper checks.
|
---|
3926 | * Note that this function will only be called when the format is around for texturing. */
|
---|
3927 | return TRUE;
|
---|
3928 | }
|
---|
3929 | return FALSE;
|
---|
3930 | }
|
---|
3931 |
|
---|
3932 | static BOOL CheckSurfaceCapability(const struct wined3d_adapter *adapter,
|
---|
3933 | const struct wined3d_format *adapter_format,
|
---|
3934 | const struct wined3d_format *check_format, BOOL no3d)
|
---|
3935 | {
|
---|
3936 | if (no3d)
|
---|
3937 | {
|
---|
3938 | switch (check_format->id)
|
---|
3939 | {
|
---|
3940 | case WINED3DFMT_B8G8R8_UNORM:
|
---|
3941 | TRACE("[FAILED] - Not enumerated on Windows.\n");
|
---|
3942 | return FALSE;
|
---|
3943 | case WINED3DFMT_B8G8R8A8_UNORM:
|
---|
3944 | case WINED3DFMT_B8G8R8X8_UNORM:
|
---|
3945 | case WINED3DFMT_B5G6R5_UNORM:
|
---|
3946 | case WINED3DFMT_B5G5R5X1_UNORM:
|
---|
3947 | case WINED3DFMT_B5G5R5A1_UNORM:
|
---|
3948 | case WINED3DFMT_B4G4R4A4_UNORM:
|
---|
3949 | case WINED3DFMT_B2G3R3_UNORM:
|
---|
3950 | case WINED3DFMT_A8_UNORM:
|
---|
3951 | case WINED3DFMT_B2G3R3A8_UNORM:
|
---|
3952 | case WINED3DFMT_B4G4R4X4_UNORM:
|
---|
3953 | case WINED3DFMT_R10G10B10A2_UNORM:
|
---|
3954 | case WINED3DFMT_R8G8B8A8_UNORM:
|
---|
3955 | case WINED3DFMT_R8G8B8X8_UNORM:
|
---|
3956 | case WINED3DFMT_R16G16_UNORM:
|
---|
3957 | case WINED3DFMT_B10G10R10A2_UNORM:
|
---|
3958 | case WINED3DFMT_R16G16B16A16_UNORM:
|
---|
3959 | case WINED3DFMT_P8_UINT:
|
---|
3960 | TRACE("[OK]\n");
|
---|
3961 | return TRUE;
|
---|
3962 | default:
|
---|
3963 | TRACE("[FAILED] - Not available on GDI surfaces.\n");
|
---|
3964 | return FALSE;
|
---|
3965 | }
|
---|
3966 | }
|
---|
3967 |
|
---|
3968 | /* All formats that are supported for textures are supported for surfaces
|
---|
3969 | * as well. */
|
---|
3970 | if (check_format->flags & WINED3DFMT_FLAG_TEXTURE)
|
---|
3971 | return TRUE;
|
---|
3972 |
|
---|
3973 | /* All depth stencil formats are supported on surfaces */
|
---|
3974 | if (CheckDepthStencilCapability(adapter, adapter_format, check_format)) return TRUE;
|
---|
3975 |
|
---|
3976 | /* If opengl can't process the format natively, the blitter may be able to convert it */
|
---|
3977 | if (adapter->blitter->blit_supported(&adapter->gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
|
---|
3978 | NULL, WINED3D_POOL_DEFAULT, 0, check_format,
|
---|
3979 | NULL, WINED3D_POOL_DEFAULT, 0, adapter_format))
|
---|
3980 | {
|
---|
3981 | TRACE("[OK]\n");
|
---|
3982 | return TRUE;
|
---|
3983 | }
|
---|
3984 |
|
---|
3985 | /* Reject other formats */
|
---|
3986 | TRACE("[FAILED]\n");
|
---|
3987 | return FALSE;
|
---|
3988 | }
|
---|
3989 |
|
---|
3990 | /* OpenGL supports mipmapping on all formats. Wrapping is unsupported, but we
|
---|
3991 | * have to report mipmapping so we cannot reject WRAPANDMIP. Tests show that
|
---|
3992 | * Windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to
|
---|
3993 | * show that wrapping is supported. The lack of filtering will sort out the
|
---|
3994 | * mipmapping capability anyway.
|
---|
3995 | *
|
---|
3996 | * For now lets report this on all formats, but in the future we may want to
|
---|
3997 | * restrict it to some should applications need that. */
|
---|
3998 | HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT adapter_idx,
|
---|
3999 | enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
|
---|
4000 | enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id)
|
---|
4001 | {
|
---|
4002 | const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
|
---|
4003 | const struct wined3d_gl_info *gl_info = &adapter->gl_info;
|
---|
4004 | const struct wined3d_format *adapter_format = wined3d_get_format(gl_info, adapter_format_id);
|
---|
4005 | const struct wined3d_format *format = wined3d_get_format(gl_info, check_format_id);
|
---|
4006 | DWORD format_flags = 0;
|
---|
4007 | DWORD allowed_usage;
|
---|
4008 |
|
---|
4009 | TRACE("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s,\n"
|
---|
4010 | "resource_type %s, check_format %s.\n",
|
---|
4011 | wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
|
---|
4012 | debug_d3dusage(usage), debug_d3dusagequery(usage), debug_d3dresourcetype(resource_type),
|
---|
4013 | debug_d3dformat(check_format_id));
|
---|
4014 |
|
---|
4015 | if (adapter_idx >= wined3d->adapter_count)
|
---|
4016 | return WINED3DERR_INVALIDCALL;
|
---|
4017 |
|
---|
4018 | switch (resource_type)
|
---|
4019 | {
|
---|
4020 | case WINED3D_RTYPE_CUBE_TEXTURE:
|
---|
4021 | if (!gl_info->supported[ARB_TEXTURE_CUBE_MAP])
|
---|
4022 | {
|
---|
4023 | TRACE("[FAILED] - No cube texture support.\n");
|
---|
4024 | return WINED3DERR_NOTAVAILABLE;
|
---|
4025 | }
|
---|
4026 |
|
---|
4027 | format_flags |= WINED3DFMT_FLAG_TEXTURE;
|
---|
4028 | allowed_usage = WINED3DUSAGE_AUTOGENMIPMAP
|
---|
4029 | | WINED3DUSAGE_DYNAMIC
|
---|
4030 | | WINED3DUSAGE_RENDERTARGET
|
---|
4031 | | WINED3DUSAGE_SOFTWAREPROCESSING
|
---|
4032 | | WINED3DUSAGE_QUERY_FILTER
|
---|
4033 | | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
|
---|
4034 | | WINED3DUSAGE_QUERY_SRGBREAD
|
---|
4035 | | WINED3DUSAGE_QUERY_SRGBWRITE
|
---|
4036 | | WINED3DUSAGE_QUERY_VERTEXTEXTURE
|
---|
4037 | | WINED3DUSAGE_QUERY_WRAPANDMIP;
|
---|
4038 | break;
|
---|
4039 |
|
---|
4040 | case WINED3D_RTYPE_SURFACE:
|
---|
4041 | if (!CheckSurfaceCapability(adapter, adapter_format, format, wined3d->flags & WINED3D_NO3D))
|
---|
4042 | {
|
---|
4043 | TRACE("[FAILED] - Not supported for plain surfaces.\n");
|
---|
4044 | return WINED3DERR_NOTAVAILABLE;
|
---|
4045 | }
|
---|
4046 |
|
---|
4047 | allowed_usage = WINED3DUSAGE_DEPTHSTENCIL
|
---|
4048 | | WINED3DUSAGE_RENDERTARGET
|
---|
4049 | | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
|
---|
4050 | break;
|
---|
4051 |
|
---|
4052 | case WINED3D_RTYPE_TEXTURE:
|
---|
4053 | if ((usage & WINED3DUSAGE_DEPTHSTENCIL) && (format->flags & WINED3DFMT_FLAG_SHADOW)
|
---|
4054 | && !gl_info->supported[ARB_SHADOW])
|
---|
4055 | {
|
---|
4056 | TRACE("[FAILED] - No shadow sampler support.\n");
|
---|
4057 | return WINED3DERR_NOTAVAILABLE;
|
---|
4058 | }
|
---|
4059 |
|
---|
4060 | format_flags |= WINED3DFMT_FLAG_TEXTURE;
|
---|
4061 | allowed_usage = WINED3DUSAGE_AUTOGENMIPMAP
|
---|
4062 | | WINED3DUSAGE_DEPTHSTENCIL
|
---|
4063 | | WINED3DUSAGE_DYNAMIC
|
---|
4064 | | WINED3DUSAGE_RENDERTARGET
|
---|
4065 | | WINED3DUSAGE_SOFTWAREPROCESSING
|
---|
4066 | | WINED3DUSAGE_QUERY_FILTER
|
---|
4067 | | WINED3DUSAGE_QUERY_LEGACYBUMPMAP
|
---|
4068 | | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
|
---|
4069 | | WINED3DUSAGE_QUERY_SRGBREAD
|
---|
4070 | | WINED3DUSAGE_QUERY_SRGBWRITE
|
---|
4071 | | WINED3DUSAGE_QUERY_VERTEXTEXTURE
|
---|
4072 | | WINED3DUSAGE_QUERY_WRAPANDMIP;
|
---|
4073 | break;
|
---|
4074 |
|
---|
4075 | case WINED3D_RTYPE_VOLUME_TEXTURE:
|
---|
4076 | case WINED3D_RTYPE_VOLUME:
|
---|
4077 | /* Volume is to VolumeTexture what Surface is to Texture, but its
|
---|
4078 | * usage caps are not documented. Most driver seem to offer
|
---|
4079 | * (nearly) the same on Volume and VolumeTexture, so do that too. */
|
---|
4080 | if (!gl_info->supported[EXT_TEXTURE3D])
|
---|
4081 | {
|
---|
4082 | TRACE("[FAILED] - No volume texture support.\n");
|
---|
4083 | return WINED3DERR_NOTAVAILABLE;
|
---|
4084 | }
|
---|
4085 |
|
---|
4086 | /* Filter formats that need conversion; For one part, this
|
---|
4087 | * conversion is unimplemented, and volume textures are huge, so
|
---|
4088 | * it would be a big performance hit. Unless we hit an application
|
---|
4089 | * needing one of those formats, don't advertize them to avoid
|
---|
4090 | * leading applications into temptation. The windows drivers don't
|
---|
4091 | * support most of those formats on volumes anyway. */
|
---|
4092 | if (format->convert)
|
---|
4093 | {
|
---|
4094 | TRACE("[FAILED] - No converted formats on volumes.\n");
|
---|
4095 | return WINED3DERR_NOTAVAILABLE;
|
---|
4096 | }
|
---|
4097 |
|
---|
4098 | /* The GL_EXT_texture_compression_s3tc spec requires that loading
|
---|
4099 | * an s3tc compressed texture results in an error. While the D3D
|
---|
4100 | * refrast does support s3tc volumes, at least the nvidia Windows
|
---|
4101 | * driver does not, so we're free not to support this format. */
|
---|
4102 | switch (check_format_id)
|
---|
4103 | {
|
---|
4104 | case WINED3DFMT_DXT1:
|
---|
4105 | case WINED3DFMT_DXT2:
|
---|
4106 | case WINED3DFMT_DXT3:
|
---|
4107 | case WINED3DFMT_DXT4:
|
---|
4108 | case WINED3DFMT_DXT5:
|
---|
4109 | TRACE("[FAILED] - DXTn does not support 3D textures.\n");
|
---|
4110 | return WINED3DERR_NOTAVAILABLE;
|
---|
4111 |
|
---|
4112 | default:
|
---|
4113 | /* Do nothing, continue with checking the format below */
|
---|
4114 | break;
|
---|
4115 | }
|
---|
4116 |
|
---|
4117 | format_flags |= WINED3DFMT_FLAG_TEXTURE;
|
---|
4118 | allowed_usage = WINED3DUSAGE_DYNAMIC
|
---|
4119 | | WINED3DUSAGE_SOFTWAREPROCESSING
|
---|
4120 | | WINED3DUSAGE_QUERY_FILTER
|
---|
4121 | | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
|
---|
4122 | | WINED3DUSAGE_QUERY_SRGBREAD
|
---|
4123 | | WINED3DUSAGE_QUERY_SRGBWRITE
|
---|
4124 | | WINED3DUSAGE_QUERY_VERTEXTEXTURE
|
---|
4125 | | WINED3DUSAGE_QUERY_WRAPANDMIP;
|
---|
4126 | break;
|
---|
4127 |
|
---|
4128 | default:
|
---|
4129 | FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type));
|
---|
4130 | return WINED3DERR_NOTAVAILABLE;
|
---|
4131 | }
|
---|
4132 |
|
---|
4133 | if ((usage & allowed_usage) != usage)
|
---|
4134 | {
|
---|
4135 | TRACE("Requested usage %#x, but resource type %s only allows %#x.\n",
|
---|
4136 | usage, debug_d3dresourcetype(resource_type), allowed_usage);
|
---|
4137 | return WINED3DERR_NOTAVAILABLE;
|
---|
4138 | }
|
---|
4139 |
|
---|
4140 | if (usage & WINED3DUSAGE_QUERY_FILTER)
|
---|
4141 | format_flags |= WINED3DFMT_FLAG_FILTERING;
|
---|
4142 | if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
|
---|
4143 | format_flags |= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
|
---|
4144 | if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
|
---|
4145 | format_flags |= WINED3DFMT_FLAG_SRGB_READ;
|
---|
4146 | if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
|
---|
4147 | format_flags |= WINED3DFMT_FLAG_SRGB_WRITE;
|
---|
4148 | if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
|
---|
4149 | format_flags |= WINED3DFMT_FLAG_VTF;
|
---|
4150 | if (usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP)
|
---|
4151 | format_flags |= WINED3DFMT_FLAG_BUMPMAP;
|
---|
4152 |
|
---|
4153 | if ((format->flags & format_flags) != format_flags)
|
---|
4154 | {
|
---|
4155 | TRACE("Requested format flags %#x, but format %s only has %#x.\n",
|
---|
4156 | format_flags, debug_d3dformat(check_format_id), format->flags);
|
---|
4157 | return WINED3DERR_NOTAVAILABLE;
|
---|
4158 | }
|
---|
4159 |
|
---|
4160 | if ((format_flags & WINED3DFMT_FLAG_TEXTURE) && (wined3d->flags & WINED3D_NO3D))
|
---|
4161 | {
|
---|
4162 | TRACE("Requested texturing support, but wined3d was created with WINED3D_NO3D.\n");
|
---|
4163 | return WINED3DERR_NOTAVAILABLE;
|
---|
4164 | }
|
---|
4165 |
|
---|
4166 | if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
|
---|
4167 | && !CheckDepthStencilCapability(adapter, adapter_format, format))
|
---|
4168 | {
|
---|
4169 | TRACE("Requested WINED3DUSAGE_DEPTHSTENCIL, but format %s is not supported for depth / stencil buffers.\n",
|
---|
4170 | debug_d3dformat(check_format_id));
|
---|
4171 | return WINED3DERR_NOTAVAILABLE;
|
---|
4172 | }
|
---|
4173 |
|
---|
4174 | if ((usage & WINED3DUSAGE_RENDERTARGET)
|
---|
4175 | && !CheckRenderTargetCapability(adapter, adapter_format, format))
|
---|
4176 | {
|
---|
4177 | TRACE("Requested WINED3DUSAGE_RENDERTARGET, but format %s is not supported for render targets.\n",
|
---|
4178 | debug_d3dformat(check_format_id));
|
---|
4179 | return WINED3DERR_NOTAVAILABLE;
|
---|
4180 | }
|
---|
4181 |
|
---|
4182 | if ((usage & WINED3DUSAGE_AUTOGENMIPMAP) && !gl_info->supported[SGIS_GENERATE_MIPMAP])
|
---|
4183 | {
|
---|
4184 | TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n");
|
---|
4185 | return WINED3DOK_NOAUTOGEN;
|
---|
4186 | }
|
---|
4187 |
|
---|
4188 | return WINED3D_OK;
|
---|
4189 | }
|
---|
4190 |
|
---|
4191 | HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d *wined3d, UINT adapter_idx,
|
---|
4192 | enum wined3d_device_type device_type, enum wined3d_format_id src_format, enum wined3d_format_id dst_format)
|
---|
4193 | {
|
---|
4194 | FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
|
---|
4195 | wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(src_format),
|
---|
4196 | debug_d3dformat(dst_format));
|
---|
4197 |
|
---|
4198 | return WINED3D_OK;
|
---|
4199 | }
|
---|
4200 |
|
---|
4201 | HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adapter_idx,
|
---|
4202 | enum wined3d_device_type device_type, enum wined3d_format_id display_format,
|
---|
4203 | enum wined3d_format_id backbuffer_format, BOOL windowed)
|
---|
4204 | {
|
---|
4205 | UINT mode_count;
|
---|
4206 | HRESULT hr;
|
---|
4207 |
|
---|
4208 | TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
|
---|
4209 | wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(display_format),
|
---|
4210 | debug_d3dformat(backbuffer_format), windowed);
|
---|
4211 |
|
---|
4212 | if (adapter_idx >= wined3d->adapter_count)
|
---|
4213 | return WINED3DERR_INVALIDCALL;
|
---|
4214 |
|
---|
4215 | /* The task of this function is to check whether a certain display / backbuffer format
|
---|
4216 | * combination is available on the given adapter. In fullscreen mode microsoft specified
|
---|
4217 | * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
|
---|
4218 | * and display format should match exactly.
|
---|
4219 | * In windowed mode format conversion can occur and this depends on the driver. When format
|
---|
4220 | * conversion is done, this function should nevertheless fail and applications need to use
|
---|
4221 | * CheckDeviceFormatConversion.
|
---|
4222 | * At the moment we assume that fullscreen and windowed have the same capabilities. */
|
---|
4223 |
|
---|
4224 | /* There are only 4 display formats. */
|
---|
4225 | if (!(display_format == WINED3DFMT_B5G6R5_UNORM
|
---|
4226 | || display_format == WINED3DFMT_B5G5R5X1_UNORM
|
---|
4227 | || display_format == WINED3DFMT_B8G8R8X8_UNORM
|
---|
4228 | || display_format == WINED3DFMT_B10G10R10A2_UNORM))
|
---|
4229 | {
|
---|
4230 | TRACE("Format %s is not supported as display format.\n", debug_d3dformat(display_format));
|
---|
4231 | return WINED3DERR_NOTAVAILABLE;
|
---|
4232 | }
|
---|
4233 |
|
---|
4234 | /* If the requested display format is not available, don't continue. */
|
---|
4235 | mode_count = wined3d_get_adapter_mode_count(wined3d, adapter_idx,
|
---|
4236 | display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN);
|
---|
4237 | if (!mode_count)
|
---|
4238 | {
|
---|
4239 | TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format));
|
---|
4240 | return WINED3DERR_NOTAVAILABLE;
|
---|
4241 | }
|
---|
4242 |
|
---|
4243 | /* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbuffer format,
|
---|
4244 | * it means 'reuse' the display format for the backbuffer. */
|
---|
4245 | if (!windowed && backbuffer_format == WINED3DFMT_UNKNOWN)
|
---|
4246 | {
|
---|
4247 | TRACE("backbuffer_format WINED3FMT_UNKNOWN only available in windowed mode.\n");
|
---|
4248 | return WINED3DERR_NOTAVAILABLE;
|
---|
4249 | }
|
---|
4250 |
|
---|
4251 | /* In FULLSCREEN mode WINED3DFMT_B5G6R5_UNORM can only be mixed with
|
---|
4252 | * backbuffer format WINED3DFMT_B5G6R5_UNORM. */
|
---|
4253 | if (display_format == WINED3DFMT_B5G6R5_UNORM && backbuffer_format != WINED3DFMT_B5G6R5_UNORM)
|
---|
4254 | {
|
---|
4255 | TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
|
---|
4256 | debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
|
---|
4257 | return WINED3DERR_NOTAVAILABLE;
|
---|
4258 | }
|
---|
4259 |
|
---|
4260 | /* In FULLSCREEN mode WINED3DFMT_B5G5R5X1_UNORM can only be mixed with
|
---|
4261 | * backbuffer formats WINED3DFMT_B5G5R5X1_UNORM and
|
---|
4262 | * WINED3DFMT_B5G5R5A1_UNORM. */
|
---|
4263 | if (display_format == WINED3DFMT_B5G5R5X1_UNORM
|
---|
4264 | && !(backbuffer_format == WINED3DFMT_B5G5R5X1_UNORM || backbuffer_format == WINED3DFMT_B5G5R5A1_UNORM))
|
---|
4265 | {
|
---|
4266 | TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
|
---|
4267 | debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
|
---|
4268 | return WINED3DERR_NOTAVAILABLE;
|
---|
4269 | }
|
---|
4270 |
|
---|
4271 | /* In FULLSCREEN mode WINED3DFMT_B8G8R8X8_UNORM can only be mixed with
|
---|
4272 | * backbuffer formats WINED3DFMT_B8G8R8X8_UNORM and
|
---|
4273 | * WINED3DFMT_B8G8R8A8_UNORM. */
|
---|
4274 | if (display_format == WINED3DFMT_B8G8R8X8_UNORM
|
---|
4275 | && !(backbuffer_format == WINED3DFMT_B8G8R8X8_UNORM || backbuffer_format == WINED3DFMT_B8G8R8A8_UNORM))
|
---|
4276 | {
|
---|
4277 | TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
|
---|
4278 | debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
|
---|
4279 | return WINED3DERR_NOTAVAILABLE;
|
---|
4280 | }
|
---|
4281 |
|
---|
4282 | /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode and it
|
---|
4283 | * can only be mixed with backbuffer format WINED3DFMT_B10G10R10A2_UNORM. */
|
---|
4284 | if (display_format == WINED3DFMT_B10G10R10A2_UNORM
|
---|
4285 | && (backbuffer_format != WINED3DFMT_B10G10R10A2_UNORM || windowed))
|
---|
4286 | {
|
---|
4287 | TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
|
---|
4288 | debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
|
---|
4289 | return WINED3DERR_NOTAVAILABLE;
|
---|
4290 | }
|
---|
4291 |
|
---|
4292 | /* Use CheckDeviceFormat to see if the backbuffer_format is usable with the given display_format */
|
---|
4293 | hr = wined3d_check_device_format(wined3d, adapter_idx, device_type, display_format,
|
---|
4294 | WINED3DUSAGE_RENDERTARGET, WINED3D_RTYPE_SURFACE, backbuffer_format);
|
---|
4295 | if (FAILED(hr))
|
---|
4296 | TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
|
---|
4297 | debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
|
---|
4298 |
|
---|
4299 | return hr;
|
---|
4300 | }
|
---|
4301 |
|
---|
4302 | HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapter_idx,
|
---|
4303 | enum wined3d_device_type device_type, WINED3DCAPS *caps)
|
---|
4304 | {
|
---|
4305 | const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
|
---|
4306 | const struct wined3d_gl_info *gl_info = &adapter->gl_info;
|
---|
4307 | struct shader_caps shader_caps;
|
---|
4308 | struct fragment_caps fragment_caps;
|
---|
4309 | struct wined3d_vertex_caps vertex_caps;
|
---|
4310 | DWORD ckey_caps, blit_caps, fx_caps, pal_caps;
|
---|
4311 |
|
---|
4312 | TRACE("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
|
---|
4313 | wined3d, adapter_idx, debug_d3ddevicetype(device_type), caps);
|
---|
4314 |
|
---|
4315 | if (adapter_idx >= wined3d->adapter_count)
|
---|
4316 | return WINED3DERR_INVALIDCALL;
|
---|
4317 |
|
---|
4318 | caps->DeviceType = (device_type == WINED3D_DEVICE_TYPE_HAL) ? WINED3D_DEVICE_TYPE_HAL : WINED3D_DEVICE_TYPE_REF;
|
---|
4319 | caps->AdapterOrdinal = adapter_idx;
|
---|
4320 |
|
---|
4321 | caps->Caps = 0;
|
---|
4322 | caps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED |
|
---|
4323 | WINED3DCAPS2_FULLSCREENGAMMA |
|
---|
4324 | WINED3DCAPS2_DYNAMICTEXTURES;
|
---|
4325 | if (gl_info->supported[SGIS_GENERATE_MIPMAP])
|
---|
4326 | caps->Caps2 |= WINED3DCAPS2_CANAUTOGENMIPMAP;
|
---|
4327 |
|
---|
4328 | caps->Caps3 = WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD |
|
---|
4329 | WINED3DCAPS3_COPY_TO_VIDMEM |
|
---|
4330 | WINED3DCAPS3_COPY_TO_SYSTEMMEM;
|
---|
4331 |
|
---|
4332 | caps->PresentationIntervals = WINED3DPRESENT_INTERVAL_IMMEDIATE |
|
---|
4333 | WINED3DPRESENT_INTERVAL_ONE;
|
---|
4334 |
|
---|
4335 | caps->CursorCaps = WINED3DCURSORCAPS_COLOR |
|
---|
4336 | WINED3DCURSORCAPS_LOWRES;
|
---|
4337 |
|
---|
4338 | caps->DevCaps = WINED3DDEVCAPS_FLOATTLVERTEX |
|
---|
4339 | WINED3DDEVCAPS_EXECUTESYSTEMMEMORY |
|
---|
4340 | WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY|
|
---|
4341 | WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY |
|
---|
4342 | WINED3DDEVCAPS_DRAWPRIMTLVERTEX |
|
---|
4343 | WINED3DDEVCAPS_HWTRANSFORMANDLIGHT |
|
---|
4344 | WINED3DDEVCAPS_EXECUTEVIDEOMEMORY |
|
---|
4345 | WINED3DDEVCAPS_PUREDEVICE |
|
---|
4346 | WINED3DDEVCAPS_HWRASTERIZATION |
|
---|
4347 | WINED3DDEVCAPS_TEXTUREVIDEOMEMORY |
|
---|
4348 | WINED3DDEVCAPS_TEXTURESYSTEMMEMORY |
|
---|
4349 | WINED3DDEVCAPS_CANRENDERAFTERFLIP |
|
---|
4350 | WINED3DDEVCAPS_DRAWPRIMITIVES2 |
|
---|
4351 | WINED3DDEVCAPS_DRAWPRIMITIVES2EX;
|
---|
4352 |
|
---|
4353 | caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE |
|
---|
4354 | WINED3DPMISCCAPS_CULLCCW |
|
---|
4355 | WINED3DPMISCCAPS_CULLCW |
|
---|
4356 | WINED3DPMISCCAPS_COLORWRITEENABLE |
|
---|
4357 | WINED3DPMISCCAPS_CLIPTLVERTS |
|
---|
4358 | WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
|
---|
4359 | WINED3DPMISCCAPS_MASKZ |
|
---|
4360 | WINED3DPMISCCAPS_BLENDOP |
|
---|
4361 | WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
|
---|
4362 | /* TODO:
|
---|
4363 | WINED3DPMISCCAPS_NULLREFERENCE
|
---|
4364 | WINED3DPMISCCAPS_FOGANDSPECULARALPHA
|
---|
4365 | WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
|
---|
4366 | WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
|
---|
4367 |
|
---|
4368 | if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
|
---|
4369 | caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
|
---|
4370 | if (gl_info->supported[EXT_DRAW_BUFFERS2])
|
---|
4371 | caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS;
|
---|
4372 | if (gl_info->supported[ARB_FRAMEBUFFER_SRGB])
|
---|
4373 | caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_POSTBLENDSRGBCONVERT;
|
---|
4374 |
|
---|
4375 | caps->RasterCaps = WINED3DPRASTERCAPS_DITHER |
|
---|
4376 | WINED3DPRASTERCAPS_PAT |
|
---|
4377 | WINED3DPRASTERCAPS_WFOG |
|
---|
4378 | WINED3DPRASTERCAPS_ZFOG |
|
---|
4379 | WINED3DPRASTERCAPS_FOGVERTEX |
|
---|
4380 | WINED3DPRASTERCAPS_FOGTABLE |
|
---|
4381 | WINED3DPRASTERCAPS_STIPPLE |
|
---|
4382 | WINED3DPRASTERCAPS_SUBPIXEL |
|
---|
4383 | WINED3DPRASTERCAPS_ZTEST |
|
---|
4384 | WINED3DPRASTERCAPS_SCISSORTEST |
|
---|
4385 | WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
|
---|
4386 | WINED3DPRASTERCAPS_DEPTHBIAS;
|
---|
4387 |
|
---|
4388 | if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
|
---|
4389 | {
|
---|
4390 | caps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY |
|
---|
4391 | WINED3DPRASTERCAPS_ZBIAS |
|
---|
4392 | WINED3DPRASTERCAPS_MIPMAPLODBIAS;
|
---|
4393 | }
|
---|
4394 |
|
---|
4395 | caps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
|
---|
4396 | WINED3DPCMPCAPS_EQUAL |
|
---|
4397 | WINED3DPCMPCAPS_GREATER |
|
---|
4398 | WINED3DPCMPCAPS_GREATEREQUAL |
|
---|
4399 | WINED3DPCMPCAPS_LESS |
|
---|
4400 | WINED3DPCMPCAPS_LESSEQUAL |
|
---|
4401 | WINED3DPCMPCAPS_NEVER |
|
---|
4402 | WINED3DPCMPCAPS_NOTEQUAL;
|
---|
4403 |
|
---|
4404 | caps->SrcBlendCaps = WINED3DPBLENDCAPS_BOTHINVSRCALPHA |
|
---|
4405 | WINED3DPBLENDCAPS_BOTHSRCALPHA |
|
---|
4406 | WINED3DPBLENDCAPS_DESTALPHA |
|
---|
4407 | WINED3DPBLENDCAPS_DESTCOLOR |
|
---|
4408 | WINED3DPBLENDCAPS_INVDESTALPHA |
|
---|
4409 | WINED3DPBLENDCAPS_INVDESTCOLOR |
|
---|
4410 | WINED3DPBLENDCAPS_INVSRCALPHA |
|
---|
4411 | WINED3DPBLENDCAPS_INVSRCCOLOR |
|
---|
4412 | WINED3DPBLENDCAPS_ONE |
|
---|
4413 | WINED3DPBLENDCAPS_SRCALPHA |
|
---|
4414 | WINED3DPBLENDCAPS_SRCALPHASAT |
|
---|
4415 | WINED3DPBLENDCAPS_SRCCOLOR |
|
---|
4416 | WINED3DPBLENDCAPS_ZERO;
|
---|
4417 |
|
---|
4418 | caps->DestBlendCaps = WINED3DPBLENDCAPS_DESTALPHA |
|
---|
4419 | WINED3DPBLENDCAPS_DESTCOLOR |
|
---|
4420 | WINED3DPBLENDCAPS_INVDESTALPHA |
|
---|
4421 | WINED3DPBLENDCAPS_INVDESTCOLOR |
|
---|
4422 | WINED3DPBLENDCAPS_INVSRCALPHA |
|
---|
4423 | WINED3DPBLENDCAPS_INVSRCCOLOR |
|
---|
4424 | WINED3DPBLENDCAPS_ONE |
|
---|
4425 | WINED3DPBLENDCAPS_SRCALPHA |
|
---|
4426 | WINED3DPBLENDCAPS_SRCCOLOR |
|
---|
4427 | WINED3DPBLENDCAPS_ZERO;
|
---|
4428 | /* NOTE: WINED3DPBLENDCAPS_SRCALPHASAT is not supported as dest blend factor,
|
---|
4429 | * according to the glBlendFunc manpage
|
---|
4430 | *
|
---|
4431 | * WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA are
|
---|
4432 | * legacy settings for srcblend only
|
---|
4433 | */
|
---|
4434 |
|
---|
4435 | if (gl_info->supported[EXT_BLEND_COLOR])
|
---|
4436 | {
|
---|
4437 | caps->SrcBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
|
---|
4438 | caps->DestBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
|
---|
4439 | }
|
---|
4440 |
|
---|
4441 |
|
---|
4442 | caps->AlphaCmpCaps = WINED3DPCMPCAPS_ALWAYS |
|
---|
4443 | WINED3DPCMPCAPS_EQUAL |
|
---|
4444 | WINED3DPCMPCAPS_GREATER |
|
---|
4445 | WINED3DPCMPCAPS_GREATEREQUAL |
|
---|
4446 | WINED3DPCMPCAPS_LESS |
|
---|
4447 | WINED3DPCMPCAPS_LESSEQUAL |
|
---|
4448 | WINED3DPCMPCAPS_NEVER |
|
---|
4449 | WINED3DPCMPCAPS_NOTEQUAL;
|
---|
4450 |
|
---|
4451 | caps->ShadeCaps = WINED3DPSHADECAPS_SPECULARGOURAUDRGB |
|
---|
4452 | WINED3DPSHADECAPS_COLORGOURAUDRGB |
|
---|
4453 | WINED3DPSHADECAPS_ALPHAFLATBLEND |
|
---|
4454 | WINED3DPSHADECAPS_ALPHAGOURAUDBLEND |
|
---|
4455 | WINED3DPSHADECAPS_COLORFLATRGB |
|
---|
4456 | WINED3DPSHADECAPS_FOGFLAT |
|
---|
4457 | WINED3DPSHADECAPS_FOGGOURAUD |
|
---|
4458 | WINED3DPSHADECAPS_SPECULARFLATRGB;
|
---|
4459 |
|
---|
4460 | caps->TextureCaps = WINED3DPTEXTURECAPS_ALPHA |
|
---|
4461 | WINED3DPTEXTURECAPS_ALPHAPALETTE |
|
---|
4462 | WINED3DPTEXTURECAPS_TRANSPARENCY |
|
---|
4463 | WINED3DPTEXTURECAPS_BORDER |
|
---|
4464 | WINED3DPTEXTURECAPS_MIPMAP |
|
---|
4465 | WINED3DPTEXTURECAPS_PROJECTED |
|
---|
4466 | WINED3DPTEXTURECAPS_PERSPECTIVE;
|
---|
4467 |
|
---|
4468 | if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
|
---|
4469 | {
|
---|
4470 | caps->TextureCaps |= WINED3DPTEXTURECAPS_POW2 |
|
---|
4471 | WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL;
|
---|
4472 | }
|
---|
4473 |
|
---|
4474 | if (gl_info->supported[EXT_TEXTURE3D])
|
---|
4475 | {
|
---|
4476 | caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP |
|
---|
4477 | WINED3DPTEXTURECAPS_MIPVOLUMEMAP;
|
---|
4478 | if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
|
---|
4479 | {
|
---|
4480 | caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2;
|
---|
4481 | }
|
---|
4482 | }
|
---|
4483 |
|
---|
4484 | if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
|
---|
4485 | {
|
---|
4486 | caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP |
|
---|
4487 | WINED3DPTEXTURECAPS_MIPCUBEMAP;
|
---|
4488 | if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
|
---|
4489 | {
|
---|
4490 | caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP_POW2;
|
---|
4491 | }
|
---|
4492 | }
|
---|
4493 |
|
---|
4494 | caps->TextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
|
---|
4495 | WINED3DPTFILTERCAPS_MAGFPOINT |
|
---|
4496 | WINED3DPTFILTERCAPS_MINFLINEAR |
|
---|
4497 | WINED3DPTFILTERCAPS_MINFPOINT |
|
---|
4498 | WINED3DPTFILTERCAPS_MIPFLINEAR |
|
---|
4499 | WINED3DPTFILTERCAPS_MIPFPOINT |
|
---|
4500 | WINED3DPTFILTERCAPS_LINEAR |
|
---|
4501 | WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
|
---|
4502 | WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
|
---|
4503 | WINED3DPTFILTERCAPS_MIPLINEAR |
|
---|
4504 | WINED3DPTFILTERCAPS_MIPNEAREST |
|
---|
4505 | WINED3DPTFILTERCAPS_NEAREST;
|
---|
4506 |
|
---|
4507 | if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
|
---|
4508 | {
|
---|
4509 | caps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
|
---|
4510 | WINED3DPTFILTERCAPS_MINFANISOTROPIC;
|
---|
4511 | }
|
---|
4512 |
|
---|
4513 | if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
|
---|
4514 | {
|
---|
4515 | caps->CubeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
|
---|
4516 | WINED3DPTFILTERCAPS_MAGFPOINT |
|
---|
4517 | WINED3DPTFILTERCAPS_MINFLINEAR |
|
---|
4518 | WINED3DPTFILTERCAPS_MINFPOINT |
|
---|
4519 | WINED3DPTFILTERCAPS_MIPFLINEAR |
|
---|
4520 | WINED3DPTFILTERCAPS_MIPFPOINT |
|
---|
4521 | WINED3DPTFILTERCAPS_LINEAR |
|
---|
4522 | WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
|
---|
4523 | WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
|
---|
4524 | WINED3DPTFILTERCAPS_MIPLINEAR |
|
---|
4525 | WINED3DPTFILTERCAPS_MIPNEAREST |
|
---|
4526 | WINED3DPTFILTERCAPS_NEAREST;
|
---|
4527 |
|
---|
4528 | if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
|
---|
4529 | {
|
---|
4530 | caps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
|
---|
4531 | WINED3DPTFILTERCAPS_MINFANISOTROPIC;
|
---|
4532 | }
|
---|
4533 | }
|
---|
4534 | else
|
---|
4535 | {
|
---|
4536 | caps->CubeTextureFilterCaps = 0;
|
---|
4537 | }
|
---|
4538 |
|
---|
4539 | if (gl_info->supported[EXT_TEXTURE3D])
|
---|
4540 | {
|
---|
4541 | caps->VolumeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
|
---|
4542 | WINED3DPTFILTERCAPS_MAGFPOINT |
|
---|
4543 | WINED3DPTFILTERCAPS_MINFLINEAR |
|
---|
4544 | WINED3DPTFILTERCAPS_MINFPOINT |
|
---|
4545 | WINED3DPTFILTERCAPS_MIPFLINEAR |
|
---|
4546 | WINED3DPTFILTERCAPS_MIPFPOINT |
|
---|
4547 | WINED3DPTFILTERCAPS_LINEAR |
|
---|
4548 | WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
|
---|
4549 | WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
|
---|
4550 | WINED3DPTFILTERCAPS_MIPLINEAR |
|
---|
4551 | WINED3DPTFILTERCAPS_MIPNEAREST |
|
---|
4552 | WINED3DPTFILTERCAPS_NEAREST;
|
---|
4553 | }
|
---|
4554 | else
|
---|
4555 | {
|
---|
4556 | caps->VolumeTextureFilterCaps = 0;
|
---|
4557 | }
|
---|
4558 |
|
---|
4559 | caps->TextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
|
---|
4560 | WINED3DPTADDRESSCAPS_CLAMP |
|
---|
4561 | WINED3DPTADDRESSCAPS_WRAP;
|
---|
4562 |
|
---|
4563 | if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
|
---|
4564 | {
|
---|
4565 | caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
|
---|
4566 | }
|
---|
4567 | if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
|
---|
4568 | {
|
---|
4569 | caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
|
---|
4570 | }
|
---|
4571 | if (gl_info->supported[ATI_TEXTURE_MIRROR_ONCE])
|
---|
4572 | {
|
---|
4573 | caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
|
---|
4574 | }
|
---|
4575 |
|
---|
4576 | if (gl_info->supported[EXT_TEXTURE3D])
|
---|
4577 | {
|
---|
4578 | caps->VolumeTextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
|
---|
4579 | WINED3DPTADDRESSCAPS_CLAMP |
|
---|
4580 | WINED3DPTADDRESSCAPS_WRAP;
|
---|
4581 | if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
|
---|
4582 | {
|
---|
4583 | caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
|
---|
4584 | }
|
---|
4585 | if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
|
---|
4586 | {
|
---|
4587 | caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
|
---|
4588 | }
|
---|
4589 | if (gl_info->supported[ATI_TEXTURE_MIRROR_ONCE])
|
---|
4590 | {
|
---|
4591 | caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
|
---|
4592 | }
|
---|
4593 | }
|
---|
4594 | else
|
---|
4595 | {
|
---|
4596 | caps->VolumeTextureAddressCaps = 0;
|
---|
4597 | }
|
---|
4598 |
|
---|
4599 | caps->LineCaps = WINED3DLINECAPS_TEXTURE |
|
---|
4600 | WINED3DLINECAPS_ZTEST |
|
---|
4601 | WINED3DLINECAPS_BLEND |
|
---|
4602 | WINED3DLINECAPS_ALPHACMP |
|
---|
4603 | WINED3DLINECAPS_FOG;
|
---|
4604 | /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
|
---|
4605 | * idea how generating the smoothing alpha values works; the result is different
|
---|
4606 | */
|
---|
4607 |
|
---|
4608 | caps->MaxTextureWidth = gl_info->limits.texture_size;
|
---|
4609 | caps->MaxTextureHeight = gl_info->limits.texture_size;
|
---|
4610 |
|
---|
4611 | if (gl_info->supported[EXT_TEXTURE3D])
|
---|
4612 | caps->MaxVolumeExtent = gl_info->limits.texture3d_size;
|
---|
4613 | else
|
---|
4614 | caps->MaxVolumeExtent = 0;
|
---|
4615 |
|
---|
4616 | caps->MaxTextureRepeat = 32768;
|
---|
4617 | caps->MaxTextureAspectRatio = gl_info->limits.texture_size;
|
---|
4618 | caps->MaxVertexW = 1.0f;
|
---|
4619 |
|
---|
4620 | caps->GuardBandLeft = 0.0f;
|
---|
4621 | caps->GuardBandTop = 0.0f;
|
---|
4622 | caps->GuardBandRight = 0.0f;
|
---|
4623 | caps->GuardBandBottom = 0.0f;
|
---|
4624 |
|
---|
4625 | caps->ExtentsAdjust = 0.0f;
|
---|
4626 |
|
---|
4627 | caps->StencilCaps = WINED3DSTENCILCAPS_DECRSAT |
|
---|
4628 | WINED3DSTENCILCAPS_INCRSAT |
|
---|
4629 | WINED3DSTENCILCAPS_INVERT |
|
---|
4630 | WINED3DSTENCILCAPS_KEEP |
|
---|
4631 | WINED3DSTENCILCAPS_REPLACE |
|
---|
4632 | WINED3DSTENCILCAPS_ZERO;
|
---|
4633 | if (gl_info->supported[EXT_STENCIL_WRAP])
|
---|
4634 | {
|
---|
4635 | caps->StencilCaps |= WINED3DSTENCILCAPS_DECR |
|
---|
4636 | WINED3DSTENCILCAPS_INCR;
|
---|
4637 | }
|
---|
4638 | if (gl_info->supported[EXT_STENCIL_TWO_SIDE] || gl_info->supported[ATI_SEPARATE_STENCIL])
|
---|
4639 | {
|
---|
4640 | caps->StencilCaps |= WINED3DSTENCILCAPS_TWOSIDED;
|
---|
4641 | }
|
---|
4642 |
|
---|
4643 | caps->MaxAnisotropy = gl_info->limits.anisotropy;
|
---|
4644 | caps->MaxPointSize = gl_info->limits.pointsize_max;
|
---|
4645 |
|
---|
4646 | caps->MaxPrimitiveCount = 0xfffff; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
|
---|
4647 | caps->MaxVertexIndex = 0xfffff;
|
---|
4648 | caps->MaxStreams = MAX_STREAMS;
|
---|
4649 | caps->MaxStreamStride = 1024;
|
---|
4650 |
|
---|
4651 | /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
|
---|
4652 | caps->DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET |
|
---|
4653 | WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
|
---|
4654 | caps->MaxNpatchTessellationLevel = 0;
|
---|
4655 | caps->MasterAdapterOrdinal = 0;
|
---|
4656 | caps->AdapterOrdinalInGroup = 0;
|
---|
4657 | caps->NumberOfAdaptersInGroup = 1;
|
---|
4658 |
|
---|
4659 | caps->NumSimultaneousRTs = gl_info->limits.buffers;
|
---|
4660 |
|
---|
4661 | caps->StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT |
|
---|
4662 | WINED3DPTFILTERCAPS_MAGFPOINT |
|
---|
4663 | WINED3DPTFILTERCAPS_MINFLINEAR |
|
---|
4664 | WINED3DPTFILTERCAPS_MAGFLINEAR;
|
---|
4665 | caps->VertexTextureFilterCaps = 0;
|
---|
4666 |
|
---|
4667 | adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
|
---|
4668 | adapter->fragment_pipe->get_caps(&adapter->gl_info, &fragment_caps);
|
---|
4669 | adapter->vertex_pipe->vp_get_caps(&adapter->gl_info, &vertex_caps);
|
---|
4670 |
|
---|
4671 | /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
|
---|
4672 | caps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps;
|
---|
4673 |
|
---|
4674 | caps->VertexShaderVersion = shader_caps.vs_version;
|
---|
4675 | caps->MaxVertexShaderConst = shader_caps.vs_uniform_count;
|
---|
4676 |
|
---|
4677 | caps->PixelShaderVersion = shader_caps.ps_version;
|
---|
4678 | caps->PixelShader1xMaxValue = shader_caps.ps_1x_max_value;
|
---|
4679 |
|
---|
4680 | caps->TextureOpCaps = fragment_caps.TextureOpCaps;
|
---|
4681 | caps->MaxTextureBlendStages = fragment_caps.MaxTextureBlendStages;
|
---|
4682 | caps->MaxSimultaneousTextures = fragment_caps.MaxSimultaneousTextures;
|
---|
4683 |
|
---|
4684 | caps->MaxUserClipPlanes = vertex_caps.max_user_clip_planes;
|
---|
4685 | caps->MaxActiveLights = vertex_caps.max_active_lights;
|
---|
4686 | caps->MaxVertexBlendMatrices = vertex_caps.max_vertex_blend_matrices;
|
---|
4687 | caps->MaxVertexBlendMatrixIndex = vertex_caps.max_vertex_blend_matrix_index;
|
---|
4688 | caps->VertexProcessingCaps = vertex_caps.vertex_processing_caps;
|
---|
4689 | caps->FVFCaps = vertex_caps.fvf_caps;
|
---|
4690 | caps->RasterCaps |= vertex_caps.raster_caps;
|
---|
4691 |
|
---|
4692 | /* The following caps are shader specific, but they are things we cannot detect, or which
|
---|
4693 | * are the same among all shader models. So to avoid code duplication set the shader version
|
---|
4694 | * specific, but otherwise constant caps here
|
---|
4695 | */
|
---|
4696 | if (caps->VertexShaderVersion >= 3)
|
---|
4697 | {
|
---|
4698 | /* Where possible set the caps based on OpenGL extensions and if they
|
---|
4699 | * aren't set (in case of software rendering) use the VS 3.0 from
|
---|
4700 | * MSDN or else if there's OpenGL spec use a hardcoded value minimum
|
---|
4701 | * VS3.0 value. */
|
---|
4702 | caps->VS20Caps.caps = WINED3DVS20CAPS_PREDICATION;
|
---|
4703 | /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
|
---|
4704 | caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH;
|
---|
4705 | caps->VS20Caps.temp_count = max(32, adapter->gl_info.limits.arb_vs_temps);
|
---|
4706 | /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
|
---|
4707 | caps->VS20Caps.static_flow_control_depth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH;
|
---|
4708 |
|
---|
4709 | caps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
|
---|
4710 | caps->MaxVertexShader30InstructionSlots = max(512, adapter->gl_info.limits.arb_vs_instructions);
|
---|
4711 | }
|
---|
4712 | else if (caps->VertexShaderVersion == 2)
|
---|
4713 | {
|
---|
4714 | caps->VS20Caps.caps = 0;
|
---|
4715 | caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
|
---|
4716 | caps->VS20Caps.temp_count = max(12, adapter->gl_info.limits.arb_vs_temps);
|
---|
4717 | caps->VS20Caps.static_flow_control_depth = 1;
|
---|
4718 |
|
---|
4719 | caps->MaxVShaderInstructionsExecuted = 65535;
|
---|
4720 | caps->MaxVertexShader30InstructionSlots = 0;
|
---|
4721 | }
|
---|
4722 | else
|
---|
4723 | { /* VS 1.x */
|
---|
4724 | caps->VS20Caps.caps = 0;
|
---|
4725 | caps->VS20Caps.dynamic_flow_control_depth = 0;
|
---|
4726 | caps->VS20Caps.temp_count = 0;
|
---|
4727 | caps->VS20Caps.static_flow_control_depth = 0;
|
---|
4728 |
|
---|
4729 | caps->MaxVShaderInstructionsExecuted = 0;
|
---|
4730 | caps->MaxVertexShader30InstructionSlots = 0;
|
---|
4731 | }
|
---|
4732 |
|
---|
4733 | if (caps->PixelShaderVersion >= 3)
|
---|
4734 | {
|
---|
4735 | /* Where possible set the caps based on OpenGL extensions and if they
|
---|
4736 | * aren't set (in case of software rendering) use the PS 3.0 from
|
---|
4737 | * MSDN or else if there's OpenGL spec use a hardcoded value minimum
|
---|
4738 | * PS 3.0 value. */
|
---|
4739 |
|
---|
4740 | /* Caps is more or less undocumented on MSDN but it appears to be
|
---|
4741 | * used for PS20Caps based on results from R9600/FX5900/Geforce6800
|
---|
4742 | * cards from Windows */
|
---|
4743 | caps->PS20Caps.caps = WINED3DPS20CAPS_ARBITRARYSWIZZLE |
|
---|
4744 | WINED3DPS20CAPS_GRADIENTINSTRUCTIONS |
|
---|
4745 | WINED3DPS20CAPS_PREDICATION |
|
---|
4746 | WINED3DPS20CAPS_NODEPENDENTREADLIMIT |
|
---|
4747 | WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT;
|
---|
4748 | /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
|
---|
4749 | caps->PS20Caps.dynamic_flow_control_depth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH;
|
---|
4750 | caps->PS20Caps.temp_count = max(32, adapter->gl_info.limits.arb_ps_temps);
|
---|
4751 | /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
|
---|
4752 | caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH;
|
---|
4753 | /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
|
---|
4754 | caps->PS20Caps.instruction_slot_count = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS;
|
---|
4755 |
|
---|
4756 | caps->MaxPShaderInstructionsExecuted = 65535;
|
---|
4757 | caps->MaxPixelShader30InstructionSlots = max(WINED3DMIN30SHADERINSTRUCTIONS,
|
---|
4758 | adapter->gl_info.limits.arb_ps_instructions);
|
---|
4759 | }
|
---|
4760 | else if(caps->PixelShaderVersion == 2)
|
---|
4761 | {
|
---|
4762 | /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
|
---|
4763 | caps->PS20Caps.caps = 0;
|
---|
4764 | caps->PS20Caps.dynamic_flow_control_depth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
|
---|
4765 | caps->PS20Caps.temp_count = max(12, adapter->gl_info.limits.arb_ps_temps);
|
---|
4766 | caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minimum: 1 */
|
---|
4767 | /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
|
---|
4768 | caps->PS20Caps.instruction_slot_count = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS;
|
---|
4769 |
|
---|
4770 | caps->MaxPShaderInstructionsExecuted = 512; /* Minimum value, a GeforceFX uses 1024 */
|
---|
4771 | caps->MaxPixelShader30InstructionSlots = 0;
|
---|
4772 | }
|
---|
4773 | else /* PS 1.x */
|
---|
4774 | {
|
---|
4775 | caps->PS20Caps.caps = 0;
|
---|
4776 | caps->PS20Caps.dynamic_flow_control_depth = 0;
|
---|
4777 | caps->PS20Caps.temp_count = 0;
|
---|
4778 | caps->PS20Caps.static_flow_control_depth = 0;
|
---|
4779 | caps->PS20Caps.instruction_slot_count = 0;
|
---|
4780 |
|
---|
4781 | caps->MaxPShaderInstructionsExecuted = 0;
|
---|
4782 | caps->MaxPixelShader30InstructionSlots = 0;
|
---|
4783 | }
|
---|
4784 |
|
---|
4785 | if (caps->VertexShaderVersion >= 2)
|
---|
4786 | {
|
---|
4787 | /* OpenGL supports all the formats below, perhaps not always
|
---|
4788 | * without conversion, but it supports them.
|
---|
4789 | * Further GLSL doesn't seem to have an official unsigned type so
|
---|
4790 | * don't advertise it yet as I'm not sure how we handle it.
|
---|
4791 | * We might need to add some clamping in the shader engine to
|
---|
4792 | * support it.
|
---|
4793 | * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
|
---|
4794 | caps->DeclTypes = WINED3DDTCAPS_UBYTE4 |
|
---|
4795 | WINED3DDTCAPS_UBYTE4N |
|
---|
4796 | WINED3DDTCAPS_SHORT2N |
|
---|
4797 | WINED3DDTCAPS_SHORT4N;
|
---|
4798 | if (gl_info->supported[ARB_HALF_FLOAT_VERTEX])
|
---|
4799 | {
|
---|
4800 | caps->DeclTypes |= WINED3DDTCAPS_FLOAT16_2 |
|
---|
4801 | WINED3DDTCAPS_FLOAT16_4;
|
---|
4802 | }
|
---|
4803 | }
|
---|
4804 | else
|
---|
4805 | {
|
---|
4806 | caps->DeclTypes = 0;
|
---|
4807 | }
|
---|
4808 |
|
---|
4809 | /* Set DirectDraw helper Caps */
|
---|
4810 | ckey_caps = WINEDDCKEYCAPS_DESTBLT |
|
---|
4811 | WINEDDCKEYCAPS_SRCBLT;
|
---|
4812 | fx_caps = WINEDDFXCAPS_BLTALPHA |
|
---|
4813 | WINEDDFXCAPS_BLTMIRRORLEFTRIGHT |
|
---|
4814 | WINEDDFXCAPS_BLTMIRRORUPDOWN |
|
---|
4815 | WINEDDFXCAPS_BLTROTATION90 |
|
---|
4816 | WINEDDFXCAPS_BLTSHRINKX |
|
---|
4817 | WINEDDFXCAPS_BLTSHRINKXN |
|
---|
4818 | WINEDDFXCAPS_BLTSHRINKY |
|
---|
4819 | WINEDDFXCAPS_BLTSHRINKXN |
|
---|
4820 | WINEDDFXCAPS_BLTSTRETCHX |
|
---|
4821 | WINEDDFXCAPS_BLTSTRETCHXN |
|
---|
4822 | WINEDDFXCAPS_BLTSTRETCHY |
|
---|
4823 | WINEDDFXCAPS_BLTSTRETCHYN;
|
---|
4824 | blit_caps = WINEDDCAPS_BLT |
|
---|
4825 | WINEDDCAPS_BLTCOLORFILL |
|
---|
4826 | WINEDDCAPS_BLTDEPTHFILL |
|
---|
4827 | WINEDDCAPS_BLTSTRETCH |
|
---|
4828 | WINEDDCAPS_CANBLTSYSMEM |
|
---|
4829 | WINEDDCAPS_CANCLIP |
|
---|
4830 | WINEDDCAPS_CANCLIPSTRETCHED |
|
---|
4831 | WINEDDCAPS_COLORKEY |
|
---|
4832 | WINEDDCAPS_COLORKEYHWASSIST |
|
---|
4833 | WINEDDCAPS_ALIGNBOUNDARYSRC;
|
---|
4834 | pal_caps = WINEDDPCAPS_8BIT |
|
---|
4835 | WINEDDPCAPS_PRIMARYSURFACE;
|
---|
4836 |
|
---|
4837 | /* Fill the ddraw caps structure */
|
---|
4838 | caps->ddraw_caps.caps = WINEDDCAPS_GDI |
|
---|
4839 | WINEDDCAPS_PALETTE |
|
---|
4840 | blit_caps;
|
---|
4841 | caps->ddraw_caps.caps2 = WINEDDCAPS2_CERTIFIED |
|
---|
4842 | WINEDDCAPS2_NOPAGELOCKREQUIRED |
|
---|
4843 | WINEDDCAPS2_PRIMARYGAMMA |
|
---|
4844 | WINEDDCAPS2_WIDESURFACES |
|
---|
4845 | WINEDDCAPS2_CANRENDERWINDOWED;
|
---|
4846 | caps->ddraw_caps.color_key_caps = ckey_caps;
|
---|
4847 | caps->ddraw_caps.fx_caps = fx_caps;
|
---|
4848 | caps->ddraw_caps.pal_caps = pal_caps;
|
---|
4849 | caps->ddraw_caps.svb_caps = blit_caps;
|
---|
4850 | caps->ddraw_caps.svb_color_key_caps = ckey_caps;
|
---|
4851 | caps->ddraw_caps.svb_fx_caps = fx_caps;
|
---|
4852 | caps->ddraw_caps.vsb_caps = blit_caps;
|
---|
4853 | caps->ddraw_caps.vsb_color_key_caps = ckey_caps;
|
---|
4854 | caps->ddraw_caps.vsb_fx_caps = fx_caps;
|
---|
4855 | caps->ddraw_caps.ssb_caps = blit_caps;
|
---|
4856 | caps->ddraw_caps.ssb_color_key_caps = ckey_caps;
|
---|
4857 | caps->ddraw_caps.ssb_fx_caps = fx_caps;
|
---|
4858 |
|
---|
4859 | caps->ddraw_caps.dds_caps = WINEDDSCAPS_ALPHA |
|
---|
4860 | WINEDDSCAPS_BACKBUFFER |
|
---|
4861 | WINEDDSCAPS_FLIP |
|
---|
4862 | WINEDDSCAPS_FRONTBUFFER |
|
---|
4863 | WINEDDSCAPS_OFFSCREENPLAIN |
|
---|
4864 | WINEDDSCAPS_PALETTE |
|
---|
4865 | WINEDDSCAPS_PRIMARYSURFACE |
|
---|
4866 | WINEDDSCAPS_SYSTEMMEMORY |
|
---|
4867 | WINEDDSCAPS_VIDEOMEMORY |
|
---|
4868 | WINEDDSCAPS_VISIBLE;
|
---|
4869 | caps->ddraw_caps.stride_align = DDRAW_PITCH_ALIGNMENT;
|
---|
4870 |
|
---|
4871 | if (!(wined3d->flags & WINED3D_NO3D))
|
---|
4872 | {
|
---|
4873 | caps->ddraw_caps.dds_caps |= WINEDDSCAPS_3DDEVICE |
|
---|
4874 | WINEDDSCAPS_MIPMAP |
|
---|
4875 | WINEDDSCAPS_TEXTURE |
|
---|
4876 | WINEDDSCAPS_ZBUFFER;
|
---|
4877 | caps->ddraw_caps.caps |= WINEDDCAPS_3D;
|
---|
4878 | }
|
---|
4879 |
|
---|
4880 | return WINED3D_OK;
|
---|
4881 | }
|
---|
4882 |
|
---|
4883 | HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, enum wined3d_device_type device_type,
|
---|
4884 | HWND focus_window, DWORD flags, BYTE surface_alignment, struct wined3d_device_parent *device_parent,
|
---|
4885 | struct wined3d_device **device)
|
---|
4886 | {
|
---|
4887 | struct wined3d_device *object;
|
---|
4888 | HRESULT hr;
|
---|
4889 |
|
---|
4890 | TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, device_parent %p, device %p.\n",
|
---|
4891 | wined3d, adapter_idx, device_type, focus_window, flags, device_parent, device);
|
---|
4892 |
|
---|
4893 | /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
|
---|
4894 | * number and create a device without a 3D adapter for 2D only operation. */
|
---|
4895 | if (wined3d->adapter_count && adapter_idx >= wined3d->adapter_count)
|
---|
4896 | return WINED3DERR_INVALIDCALL;
|
---|
4897 |
|
---|
4898 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
---|
4899 | if (!object)
|
---|
4900 | return E_OUTOFMEMORY;
|
---|
4901 |
|
---|
4902 | hr = device_init(object, wined3d, adapter_idx, device_type,
|
---|
4903 | focus_window, flags, surface_alignment, device_parent);
|
---|
4904 | if (FAILED(hr))
|
---|
4905 | {
|
---|
4906 | WARN("Failed to initialize device, hr %#x.\n", hr);
|
---|
4907 | HeapFree(GetProcessHeap(), 0, object);
|
---|
4908 | return hr;
|
---|
4909 | }
|
---|
4910 |
|
---|
4911 | TRACE("Created device %p.\n", object);
|
---|
4912 | *device = object;
|
---|
4913 |
|
---|
4914 | device_parent->ops->wined3d_device_created(device_parent, *device);
|
---|
4915 |
|
---|
4916 | return WINED3D_OK;
|
---|
4917 | }
|
---|
4918 |
|
---|
4919 | static void WINE_GLAPI invalid_func(const void *data)
|
---|
4920 | {
|
---|
4921 | ERR("Invalid vertex attribute function called\n");
|
---|
4922 | DebugBreak();
|
---|
4923 | }
|
---|
4924 |
|
---|
4925 | static void WINE_GLAPI invalid_texcoord_func(GLenum unit, const void *data)
|
---|
4926 | {
|
---|
4927 | ERR("Invalid texcoord function called\n");
|
---|
4928 | DebugBreak();
|
---|
4929 | }
|
---|
4930 |
|
---|
4931 | /* Helper functions for providing vertex data to opengl. The arrays are initialized based on
|
---|
4932 | * the extension detection and are used in drawStridedSlow
|
---|
4933 | */
|
---|
4934 | static void WINE_GLAPI position_d3dcolor(const void *data)
|
---|
4935 | {
|
---|
4936 | DWORD pos = *((const DWORD *)data);
|
---|
4937 |
|
---|
4938 | FIXME("Add a test for fixed function position from d3dcolor type\n");
|
---|
4939 | context_get_current()->gl_info->gl_ops.gl.p_glVertex4s(D3DCOLOR_B_R(pos),
|
---|
4940 | D3DCOLOR_B_G(pos),
|
---|
4941 | D3DCOLOR_B_B(pos),
|
---|
4942 | D3DCOLOR_B_A(pos));
|
---|
4943 | }
|
---|
4944 |
|
---|
4945 | static void WINE_GLAPI position_float4(const void *data)
|
---|
4946 | {
|
---|
4947 | const GLfloat *pos = data;
|
---|
4948 |
|
---|
4949 | if (pos[3] != 0.0f && pos[3] != 1.0f)
|
---|
4950 | {
|
---|
4951 | float w = 1.0f / pos[3];
|
---|
4952 |
|
---|
4953 | context_get_current()->gl_info->gl_ops.gl.p_glVertex4f(pos[0] * w, pos[1] * w, pos[2] * w, w);
|
---|
4954 | }
|
---|
4955 | else
|
---|
4956 | {
|
---|
4957 | context_get_current()->gl_info->gl_ops.gl.p_glVertex3fv(pos);
|
---|
4958 | }
|
---|
4959 | }
|
---|
4960 |
|
---|
4961 | static void WINE_GLAPI diffuse_d3dcolor(const void *data)
|
---|
4962 | {
|
---|
4963 | DWORD diffuseColor = *((const DWORD *)data);
|
---|
4964 |
|
---|
4965 | context_get_current()->gl_info->gl_ops.gl.p_glColor4ub(D3DCOLOR_B_R(diffuseColor),
|
---|
4966 | D3DCOLOR_B_G(diffuseColor),
|
---|
4967 | D3DCOLOR_B_B(diffuseColor),
|
---|
4968 | D3DCOLOR_B_A(diffuseColor));
|
---|
4969 | }
|
---|
4970 |
|
---|
4971 | static void WINE_GLAPI specular_d3dcolor(const void *data)
|
---|
4972 | {
|
---|
4973 | DWORD specularColor = *((const DWORD *)data);
|
---|
4974 | GLbyte d[] = {D3DCOLOR_B_R(specularColor),
|
---|
4975 | D3DCOLOR_B_G(specularColor),
|
---|
4976 | D3DCOLOR_B_B(specularColor)};
|
---|
4977 |
|
---|
4978 | specular_func_3ubv(d);
|
---|
4979 | }
|
---|
4980 |
|
---|
4981 | static void WINE_GLAPI warn_no_specular_func(const void *data)
|
---|
4982 | {
|
---|
4983 | WARN("GL_EXT_secondary_color not supported\n");
|
---|
4984 | }
|
---|
4985 |
|
---|
4986 | static void wined3d_adapter_init_ffp_attrib_ops(const struct wined3d_adapter *adapter)
|
---|
4987 | {
|
---|
4988 | const struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
|
---|
4989 | const struct wined3d_gl_info *gl_info = &adapter->gl_info;
|
---|
4990 |
|
---|
4991 | position_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
|
---|
4992 | position_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
|
---|
4993 | position_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)gl_info->gl_ops.gl.p_glVertex3fv;
|
---|
4994 | if (!d3d_info->xyzrhw)
|
---|
4995 | position_funcs[WINED3D_FFP_EMIT_FLOAT4] = position_float4;
|
---|
4996 | else
|
---|
4997 | position_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glAttribFunc)gl_info->gl_ops.gl.p_glVertex4fv;
|
---|
4998 | position_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = position_d3dcolor;
|
---|
4999 | position_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
|
---|
5000 | position_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
|
---|
5001 | position_funcs[WINED3D_FFP_EMIT_SHORT4] = (glAttribFunc)gl_info->gl_ops.gl.p_glVertex2sv;
|
---|
5002 | position_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
|
---|
5003 | position_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
|
---|
5004 | position_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
|
---|
5005 | position_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
|
---|
5006 | position_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
|
---|
5007 | position_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
|
---|
5008 | position_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
|
---|
5009 | position_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
|
---|
5010 | position_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
|
---|
5011 | position_funcs[WINED3D_FFP_EMIT_INVALID] = invalid_func;
|
---|
5012 |
|
---|
5013 | diffuse_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
|
---|
5014 | diffuse_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
|
---|
5015 | diffuse_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor3fv;
|
---|
5016 | diffuse_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor4fv;
|
---|
5017 | diffuse_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = diffuse_d3dcolor;
|
---|
5018 | diffuse_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
|
---|
5019 | diffuse_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
|
---|
5020 | diffuse_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
|
---|
5021 | diffuse_funcs[WINED3D_FFP_EMIT_UBYTE4N] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor4ubv;
|
---|
5022 | diffuse_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
|
---|
5023 | diffuse_funcs[WINED3D_FFP_EMIT_SHORT4N] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor4sv;
|
---|
5024 | diffuse_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
|
---|
5025 | diffuse_funcs[WINED3D_FFP_EMIT_USHORT4N] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor4usv;
|
---|
5026 | diffuse_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
|
---|
5027 | diffuse_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
|
---|
5028 | diffuse_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
|
---|
5029 | diffuse_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
|
---|
5030 | diffuse_funcs[WINED3D_FFP_EMIT_INVALID] = invalid_func;
|
---|
5031 |
|
---|
5032 | /* No 4 component entry points here */
|
---|
5033 | specular_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
|
---|
5034 | specular_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
|
---|
5035 | if (gl_info->supported[EXT_SECONDARY_COLOR])
|
---|
5036 | {
|
---|
5037 | specular_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)GL_EXTCALL(glSecondaryColor3fvEXT);
|
---|
5038 | }
|
---|
5039 | else
|
---|
5040 | {
|
---|
5041 | specular_funcs[WINED3D_FFP_EMIT_FLOAT3] = warn_no_specular_func;
|
---|
5042 | }
|
---|
5043 | specular_funcs[WINED3D_FFP_EMIT_FLOAT4] = invalid_func;
|
---|
5044 | if (gl_info->supported[EXT_SECONDARY_COLOR])
|
---|
5045 | {
|
---|
5046 | specular_func_3ubv = (glAttribFunc)GL_EXTCALL(glSecondaryColor3ubvEXT);
|
---|
5047 | specular_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = specular_d3dcolor;
|
---|
5048 | }
|
---|
5049 | else
|
---|
5050 | {
|
---|
5051 | specular_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = warn_no_specular_func;
|
---|
5052 | }
|
---|
5053 | specular_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
|
---|
5054 | specular_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
|
---|
5055 | specular_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
|
---|
5056 | specular_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
|
---|
5057 | specular_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
|
---|
5058 | specular_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
|
---|
5059 | specular_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
|
---|
5060 | specular_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
|
---|
5061 | specular_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
|
---|
5062 | specular_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
|
---|
5063 | specular_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
|
---|
5064 | specular_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
|
---|
5065 | specular_funcs[WINED3D_FFP_EMIT_INVALID] = invalid_func;
|
---|
5066 |
|
---|
5067 | /* Only 3 component entry points here. Test how others behave. Float4 normals are used
|
---|
5068 | * by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
|
---|
5069 | */
|
---|
5070 | normal_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
|
---|
5071 | normal_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
|
---|
5072 | normal_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)gl_info->gl_ops.gl.p_glNormal3fv;
|
---|
5073 | normal_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glAttribFunc)gl_info->gl_ops.gl.p_glNormal3fv; /* Just ignore the 4th value */
|
---|
5074 | normal_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = invalid_func;
|
---|
5075 | normal_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
|
---|
5076 | normal_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
|
---|
5077 | normal_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
|
---|
5078 | normal_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
|
---|
5079 | normal_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
|
---|
5080 | normal_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
|
---|
5081 | normal_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
|
---|
5082 | normal_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
|
---|
5083 | normal_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
|
---|
5084 | normal_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
|
---|
5085 | normal_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
|
---|
5086 | normal_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
|
---|
5087 | normal_funcs[WINED3D_FFP_EMIT_INVALID] = invalid_func;
|
---|
5088 |
|
---|
5089 | multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT1] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord1fvARB);
|
---|
5090 | multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2fvARB);
|
---|
5091 | multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord3fvARB);
|
---|
5092 | multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4fvARB);
|
---|
5093 | multi_texcoord_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = invalid_texcoord_func;
|
---|
5094 | multi_texcoord_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_texcoord_func;
|
---|
5095 | multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2svARB);
|
---|
5096 | multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4svARB);
|
---|
5097 | multi_texcoord_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_texcoord_func;
|
---|
5098 | multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_texcoord_func;
|
---|
5099 | multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_texcoord_func;
|
---|
5100 | multi_texcoord_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_texcoord_func;
|
---|
5101 | multi_texcoord_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_texcoord_func;
|
---|
5102 | multi_texcoord_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_texcoord_func;
|
---|
5103 | multi_texcoord_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_texcoord_func;
|
---|
5104 | if (gl_info->supported[NV_HALF_FLOAT])
|
---|
5105 | {
|
---|
5106 | /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT */
|
---|
5107 | multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2hvNV);
|
---|
5108 | multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4hvNV);
|
---|
5109 | } else {
|
---|
5110 | multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_texcoord_func;
|
---|
5111 | multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_texcoord_func;
|
---|
5112 | }
|
---|
5113 | multi_texcoord_funcs[WINED3D_FFP_EMIT_INVALID] = invalid_texcoord_func;
|
---|
5114 | }
|
---|
5115 |
|
---|
5116 | static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter *adapter, HDC dc)
|
---|
5117 | {
|
---|
5118 | const struct wined3d_gl_info *gl_info = &adapter->gl_info;
|
---|
5119 | int i;
|
---|
5120 |
|
---|
5121 | if (gl_info->supported[WGL_ARB_PIXEL_FORMAT])
|
---|
5122 | {
|
---|
5123 | UINT attrib_count = 0;
|
---|
5124 | GLint cfg_count;
|
---|
5125 | int attribs[11];
|
---|
5126 | int values[11];
|
---|
5127 | int attribute;
|
---|
5128 |
|
---|
5129 | attribute = WGL_NUMBER_PIXEL_FORMATS_ARB;
|
---|
5130 | GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, 0, 0, 1, &attribute, &cfg_count));
|
---|
5131 |
|
---|
5132 | adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cfg_count * sizeof(*adapter->cfgs));
|
---|
5133 | attribs[attrib_count++] = WGL_RED_BITS_ARB;
|
---|
5134 | attribs[attrib_count++] = WGL_GREEN_BITS_ARB;
|
---|
5135 | attribs[attrib_count++] = WGL_BLUE_BITS_ARB;
|
---|
5136 | attribs[attrib_count++] = WGL_ALPHA_BITS_ARB;
|
---|
5137 | attribs[attrib_count++] = WGL_COLOR_BITS_ARB;
|
---|
5138 | attribs[attrib_count++] = WGL_DEPTH_BITS_ARB;
|
---|
5139 | attribs[attrib_count++] = WGL_STENCIL_BITS_ARB;
|
---|
5140 | attribs[attrib_count++] = WGL_DRAW_TO_WINDOW_ARB;
|
---|
5141 | attribs[attrib_count++] = WGL_PIXEL_TYPE_ARB;
|
---|
5142 | attribs[attrib_count++] = WGL_DOUBLE_BUFFER_ARB;
|
---|
5143 | attribs[attrib_count++] = WGL_AUX_BUFFERS_ARB;
|
---|
5144 |
|
---|
5145 | for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
|
---|
5146 | {
|
---|
5147 | struct wined3d_pixel_format *cfg = &adapter->cfgs[adapter->cfg_count];
|
---|
5148 | int format_id = i + 1;
|
---|
5149 |
|
---|
5150 | if (!GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, format_id, 0, attrib_count, attribs, values)))
|
---|
5151 | continue;
|
---|
5152 |
|
---|
5153 | cfg->iPixelFormat = format_id;
|
---|
5154 | cfg->redSize = values[0];
|
---|
5155 | cfg->greenSize = values[1];
|
---|
5156 | cfg->blueSize = values[2];
|
---|
5157 | cfg->alphaSize = values[3];
|
---|
5158 | cfg->colorSize = values[4];
|
---|
5159 | cfg->depthSize = values[5];
|
---|
5160 | cfg->stencilSize = values[6];
|
---|
5161 | cfg->windowDrawable = values[7];
|
---|
5162 | cfg->iPixelType = values[8];
|
---|
5163 | cfg->doubleBuffer = values[9];
|
---|
5164 | cfg->auxBuffers = values[10];
|
---|
5165 |
|
---|
5166 | cfg->numSamples = 0;
|
---|
5167 | /* Check multisample support. */
|
---|
5168 | if (gl_info->supported[ARB_MULTISAMPLE])
|
---|
5169 | {
|
---|
5170 | int attribs[2] = {WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB};
|
---|
5171 | int values[2];
|
---|
5172 |
|
---|
5173 | if (GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, format_id, 0, 2, attribs, values)))
|
---|
5174 | {
|
---|
5175 | /* values[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether
|
---|
5176 | * multisampling is supported. values[1] = number of
|
---|
5177 | * multisample buffers. */
|
---|
5178 | if (values[0])
|
---|
5179 | cfg->numSamples = values[1];
|
---|
5180 | }
|
---|
5181 | }
|
---|
5182 |
|
---|
5183 | TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
|
---|
5184 | "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
|
---|
5185 | cfg->iPixelFormat, cfg->iPixelType, cfg->doubleBuffer,
|
---|
5186 | cfg->redSize, cfg->greenSize, cfg->blueSize, cfg->alphaSize,
|
---|
5187 | cfg->depthSize, cfg->stencilSize, cfg->numSamples, cfg->windowDrawable);
|
---|
5188 |
|
---|
5189 | ++adapter->cfg_count;
|
---|
5190 | }
|
---|
5191 | }
|
---|
5192 | else
|
---|
5193 | {
|
---|
5194 | int cfg_count;
|
---|
5195 |
|
---|
5196 | cfg_count = DescribePixelFormat(dc, 0, 0, 0);
|
---|
5197 | adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cfg_count * sizeof(*adapter->cfgs));
|
---|
5198 |
|
---|
5199 | for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
|
---|
5200 | {
|
---|
5201 | struct wined3d_pixel_format *cfg = &adapter->cfgs[adapter->cfg_count];
|
---|
5202 | PIXELFORMATDESCRIPTOR pfd;
|
---|
5203 | int format_id = i + 1;
|
---|
5204 |
|
---|
5205 | if (!DescribePixelFormat(dc, format_id, sizeof(pfd), &pfd))
|
---|
5206 | continue;
|
---|
5207 |
|
---|
5208 | /* We only want HW acceleration using an OpenGL ICD driver.
|
---|
5209 | * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering.
|
---|
5210 | * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD
|
---|
5211 | * driver (e.g. 3dfx minigl). */
|
---|
5212 | if (pfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED))
|
---|
5213 | {
|
---|
5214 | TRACE("Skipping format %d because it isn't ICD accelerated.\n", format_id);
|
---|
5215 | continue;
|
---|
5216 | }
|
---|
5217 |
|
---|
5218 | cfg->iPixelFormat = format_id;
|
---|
5219 | cfg->redSize = pfd.cRedBits;
|
---|
5220 | cfg->greenSize = pfd.cGreenBits;
|
---|
5221 | cfg->blueSize = pfd.cBlueBits;
|
---|
5222 | cfg->alphaSize = pfd.cAlphaBits;
|
---|
5223 | cfg->colorSize = pfd.cColorBits;
|
---|
5224 | cfg->depthSize = pfd.cDepthBits;
|
---|
5225 | cfg->stencilSize = pfd.cStencilBits;
|
---|
5226 | cfg->windowDrawable = (pfd.dwFlags & PFD_DRAW_TO_WINDOW) ? 1 : 0;
|
---|
5227 | cfg->iPixelType = (pfd.iPixelType == PFD_TYPE_RGBA) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB;
|
---|
5228 | cfg->doubleBuffer = (pfd.dwFlags & PFD_DOUBLEBUFFER) ? 1 : 0;
|
---|
5229 | cfg->auxBuffers = pfd.cAuxBuffers;
|
---|
5230 | cfg->numSamples = 0;
|
---|
5231 |
|
---|
5232 | TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
|
---|
5233 | "depth=%d, stencil=%d, windowDrawable=%d\n",
|
---|
5234 | cfg->iPixelFormat, cfg->iPixelType, cfg->doubleBuffer,
|
---|
5235 | cfg->redSize, cfg->greenSize, cfg->blueSize, cfg->alphaSize,
|
---|
5236 | cfg->depthSize, cfg->stencilSize, cfg->windowDrawable);
|
---|
5237 |
|
---|
5238 | ++adapter->cfg_count;
|
---|
5239 | }
|
---|
5240 | }
|
---|
5241 | }
|
---|
5242 |
|
---|
5243 | /**
|
---|
5244 | * Loads a system DLL.
|
---|
5245 | *
|
---|
5246 | * @returns Module handle or NULL
|
---|
5247 | * @param pszName The DLL name.
|
---|
5248 | */
|
---|
5249 | static HMODULE loadSystemDll(const char *pszName)
|
---|
5250 | {
|
---|
5251 | char szPath[MAX_PATH];
|
---|
5252 | UINT cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));
|
---|
5253 | size_t cbName = strlen(pszName) + 1;
|
---|
5254 | if (cchPath + 1 + cbName > sizeof(szPath))
|
---|
5255 | return NULL;
|
---|
5256 | szPath[cchPath] = '\\';
|
---|
5257 | memcpy(&szPath[cchPath + 1], pszName, cbName);
|
---|
5258 | return LoadLibraryA(szPath);
|
---|
5259 | }
|
---|
5260 |
|
---|
5261 | /* Do not call while under the GL lock. */
|
---|
5262 | static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal)
|
---|
5263 | {
|
---|
5264 | struct wined3d_gl_info *gl_info = &adapter->gl_info;
|
---|
5265 | struct wined3d_fake_gl_ctx fake_gl_ctx = {0};
|
---|
5266 | unsigned int ctx_attrib_idx = 0;
|
---|
5267 | DISPLAY_DEVICEW display_device;
|
---|
5268 | GLint ctx_attribs[3];
|
---|
5269 | #ifdef VBOX
|
---|
5270 | struct VBOXUHGSMI *pHgsmi = NULL;
|
---|
5271 | #endif
|
---|
5272 |
|
---|
5273 | TRACE("adapter %p, ordinal %u.\n", adapter, ordinal);
|
---|
5274 |
|
---|
5275 | adapter->ordinal = ordinal;
|
---|
5276 | adapter->monitorPoint.x = -1;
|
---|
5277 | adapter->monitorPoint.y = -1;
|
---|
5278 |
|
---|
5279 | /* Dynamically load all GL core functions */
|
---|
5280 | #ifdef USE_WIN32_OPENGL
|
---|
5281 | {
|
---|
5282 | # ifndef VBOX
|
---|
5283 | HMODULE mod_gl = GetModuleHandleA("opengl32.dll");
|
---|
5284 | # else
|
---|
5285 | BOOL (APIENTRY *pDrvValidateVersion)(DWORD) DECLSPEC_HIDDEN;
|
---|
5286 | # ifdef VBOX_WDDM_WOW64
|
---|
5287 | HMODULE mod_gl = loadSystemDll("VBoxOGL-x86.dll");
|
---|
5288 | # else
|
---|
5289 | HMODULE mod_gl = loadSystemDll("VBoxOGL.dll");
|
---|
5290 | # endif
|
---|
5291 | if (!mod_gl)
|
---|
5292 | {
|
---|
5293 | ERR("Can't load VBoxOGL.dll!\n");
|
---|
5294 | return FALSE;
|
---|
5295 | }
|
---|
5296 |
|
---|
5297 | pDrvValidateVersion = (void*)GetProcAddress(mod_gl, "DrvValidateVersion");
|
---|
5298 | if(!pDrvValidateVersion) {
|
---|
5299 | ERR("Can't get DrvValidateVersion\n");
|
---|
5300 | FreeLibrary(mod_gl);
|
---|
5301 | return FALSE;
|
---|
5302 | }
|
---|
5303 | if(!pDrvValidateVersion(1)) {
|
---|
5304 | ERR("DrvValidateVersion FAILED\n");
|
---|
5305 | FreeLibrary(mod_gl);
|
---|
5306 | return FALSE;
|
---|
5307 | }
|
---|
5308 |
|
---|
5309 | # define VBOX_USE_FUNC(f) p##f = (void *)GetProcAddress(mod_gl, #f);
|
---|
5310 | VBOX_GL_FUNCS_GEN
|
---|
5311 | # undef VBOX_USE_FUNC
|
---|
5312 | # endif
|
---|
5313 | # define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
|
---|
5314 | ALL_WGL_FUNCS
|
---|
5315 | # undef USE_GL_FUNC
|
---|
5316 | gl_info->gl_ops.wgl.p_wglSwapBuffers = (void *)GetProcAddress(mod_gl, "wglSwapBuffers");
|
---|
5317 | }
|
---|
5318 | #else
|
---|
5319 | /* To bypass the opengl32 thunks retrieve functions from the WGL driver instead of opengl32 */
|
---|
5320 | {
|
---|
5321 | HDC hdc = GetDC( 0 );
|
---|
5322 | const struct opengl_funcs *wgl_driver = __wine_get_wgl_driver( hdc, WINE_WGL_DRIVER_VERSION );
|
---|
5323 | ReleaseDC( 0, hdc );
|
---|
5324 | if (!wgl_driver || wgl_driver == (void *)-1) return FALSE;
|
---|
5325 | gl_info->gl_ops.wgl = wgl_driver->wgl;
|
---|
5326 | gl_info->gl_ops.gl = wgl_driver->gl;
|
---|
5327 | }
|
---|
5328 | #endif
|
---|
5329 |
|
---|
5330 | glEnableWINE = gl_info->gl_ops.gl.p_glEnable;
|
---|
5331 | glDisableWINE = gl_info->gl_ops.gl.p_glDisable;
|
---|
5332 |
|
---|
5333 | #ifdef VBOX_WITH_WDDM
|
---|
5334 | pHgsmi = VBoxCrHgsmiCreate();
|
---|
5335 | if (!pHgsmi)
|
---|
5336 | {
|
---|
5337 | ERR("VBoxCrHgsmiCreate failed");
|
---|
5338 | return FALSE;
|
---|
5339 | }
|
---|
5340 | #endif
|
---|
5341 |
|
---|
5342 | if (!AllocateLocallyUniqueId(&adapter->luid))
|
---|
5343 | {
|
---|
5344 | ERR("Failed to set adapter LUID (%#x).\n", GetLastError());
|
---|
5345 | return FALSE;
|
---|
5346 | }
|
---|
5347 | TRACE("Allocated LUID %08x:%08x for adapter %p.\n",
|
---|
5348 | adapter->luid.HighPart, adapter->luid.LowPart, adapter);
|
---|
5349 |
|
---|
5350 | if (!WineD3D_CreateFakeGLContext(&fake_gl_ctx
|
---|
5351 | #ifdef VBOX
|
---|
5352 | , pHgsmi
|
---|
5353 | #endif
|
---|
5354 | ))
|
---|
5355 | {
|
---|
5356 | ERR("Failed to get a GL context for adapter %p.\n", adapter);
|
---|
5357 | #ifdef VBOX_WITH_WDDM
|
---|
5358 | VBoxCrHgsmiDestroy(pHgsmi);
|
---|
5359 | #endif
|
---|
5360 | return FALSE;
|
---|
5361 | }
|
---|
5362 |
|
---|
5363 | if (context_debug_output_enabled(gl_info))
|
---|
5364 | {
|
---|
5365 | ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_FLAGS_ARB;
|
---|
5366 | ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_DEBUG_BIT_ARB;
|
---|
5367 | }
|
---|
5368 | ctx_attribs[ctx_attrib_idx] = 0;
|
---|
5369 | wined3d_create_fake_gl_context_attribs(&fake_gl_ctx, gl_info, ctx_attribs);
|
---|
5370 |
|
---|
5371 | if (!wined3d_adapter_init_gl_caps(adapter))
|
---|
5372 | {
|
---|
5373 | ERR("Failed to initialize GL caps for adapter %p.\n", adapter);
|
---|
5374 | WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
|
---|
5375 | #ifdef VBOX_WITH_WDDM
|
---|
5376 | VBoxCrHgsmiDestroy(pHgsmi);
|
---|
5377 | #endif
|
---|
5378 | return FALSE;
|
---|
5379 | }
|
---|
5380 |
|
---|
5381 | wined3d_adapter_init_fb_cfgs(adapter, fake_gl_ctx.dc);
|
---|
5382 | /* We haven't found any suitable formats. This should only happen in
|
---|
5383 | * case of GDI software rendering, which is pretty useless anyway. */
|
---|
5384 | if (!adapter->cfg_count)
|
---|
5385 | {
|
---|
5386 | WARN("No suitable pixel formats found.\n");
|
---|
5387 | WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
|
---|
5388 | HeapFree(GetProcessHeap(), 0, adapter->cfgs);
|
---|
5389 | #ifdef VBOX_WITH_WDDM
|
---|
5390 | VBoxCrHgsmiDestroy(pHgsmi);
|
---|
5391 | #endif
|
---|
5392 | return FALSE;
|
---|
5393 | }
|
---|
5394 |
|
---|
5395 | if (!wined3d_adapter_init_format_info(adapter))
|
---|
5396 | {
|
---|
5397 | ERR("Failed to initialize GL format info.\n");
|
---|
5398 | WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
|
---|
5399 | HeapFree(GetProcessHeap(), 0, adapter->cfgs);
|
---|
5400 | #ifdef VBOX_WITH_WDDM
|
---|
5401 | VBoxCrHgsmiDestroy(pHgsmi);
|
---|
5402 | #endif
|
---|
5403 | return FALSE;
|
---|
5404 | }
|
---|
5405 |
|
---|
5406 | #ifndef VBOX_WITH_WDDM
|
---|
5407 | adapter->TextureRam = adapter->driver_info.vidmem;
|
---|
5408 | adapter->UsedTextureRam = 0;
|
---|
5409 | TRACE("Emulating %u MB of texture ram.\n", adapter->TextureRam / (1024 * 1024));
|
---|
5410 | #endif
|
---|
5411 |
|
---|
5412 | display_device.cb = sizeof(display_device);
|
---|
5413 | EnumDisplayDevicesW(NULL, ordinal, &display_device, 0);
|
---|
5414 | TRACE("DeviceName: %s\n", debugstr_w(display_device.DeviceName));
|
---|
5415 | strcpyW(adapter->DeviceName, display_device.DeviceName);
|
---|
5416 |
|
---|
5417 | WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
|
---|
5418 |
|
---|
5419 | wined3d_adapter_init_ffp_attrib_ops(adapter);
|
---|
5420 |
|
---|
5421 | #ifdef VBOX_WITH_WDDM
|
---|
5422 | VBoxCrHgsmiDestroy(pHgsmi);
|
---|
5423 | #endif
|
---|
5424 |
|
---|
5425 | return TRUE;
|
---|
5426 | }
|
---|
5427 |
|
---|
5428 | static void wined3d_adapter_init_nogl(struct wined3d_adapter *adapter, UINT ordinal)
|
---|
5429 | {
|
---|
5430 | DISPLAY_DEVICEW display_device;
|
---|
5431 |
|
---|
5432 | memset(adapter, 0, sizeof(*adapter));
|
---|
5433 | adapter->ordinal = ordinal;
|
---|
5434 | adapter->monitorPoint.x = -1;
|
---|
5435 | adapter->monitorPoint.y = -1;
|
---|
5436 |
|
---|
5437 | adapter->driver_info.name = "Display";
|
---|
5438 | adapter->driver_info.description = "WineD3D DirectDraw Emulation";
|
---|
5439 | #ifndef VBOX_WITH_WDDM
|
---|
5440 | if (wined3d_settings.emulated_textureram)
|
---|
5441 | adapter->TextureRam = wined3d_settings.emulated_textureram;
|
---|
5442 | else
|
---|
5443 | adapter->TextureRam = 128 * 1024 * 1024;
|
---|
5444 | #endif
|
---|
5445 |
|
---|
5446 | initPixelFormatsNoGL(&adapter->gl_info);
|
---|
5447 |
|
---|
5448 | adapter->vertex_pipe = &none_vertex_pipe;
|
---|
5449 | adapter->fragment_pipe = &none_fragment_pipe;
|
---|
5450 | adapter->shader_backend = &none_shader_backend;
|
---|
5451 | adapter->blitter = &cpu_blit;
|
---|
5452 |
|
---|
5453 | display_device.cb = sizeof(display_device);
|
---|
5454 | EnumDisplayDevicesW(NULL, ordinal, &display_device, 0);
|
---|
5455 | TRACE("DeviceName: %s\n", debugstr_w(display_device.DeviceName));
|
---|
5456 | strcpyW(adapter->DeviceName, display_device.DeviceName);
|
---|
5457 | }
|
---|
5458 |
|
---|
5459 | static void STDMETHODCALLTYPE wined3d_null_wined3d_object_destroyed(void *parent) {}
|
---|
5460 |
|
---|
5461 | const struct wined3d_parent_ops wined3d_null_parent_ops =
|
---|
5462 | {
|
---|
5463 | wined3d_null_wined3d_object_destroyed,
|
---|
5464 | };
|
---|
5465 |
|
---|
5466 | /* Do not call while under the GL lock. */
|
---|
5467 | HRESULT wined3d_init(struct wined3d *wined3d, UINT version, DWORD flags)
|
---|
5468 | {
|
---|
5469 | wined3d->dxVersion = version;
|
---|
5470 | wined3d->ref = 1;
|
---|
5471 | wined3d->flags = flags;
|
---|
5472 |
|
---|
5473 | TRACE("Initializing adapters.\n");
|
---|
5474 |
|
---|
5475 | if (flags & WINED3D_NO3D)
|
---|
5476 | {
|
---|
5477 | wined3d_adapter_init_nogl(&wined3d->adapters[0], 0);
|
---|
5478 | wined3d->adapter_count = 1;
|
---|
5479 | return WINED3D_OK;
|
---|
5480 | }
|
---|
5481 |
|
---|
5482 | if (!wined3d_adapter_init(&wined3d->adapters[0], 0))
|
---|
5483 | {
|
---|
5484 | WARN("Failed to initialize adapter.\n");
|
---|
5485 | return E_FAIL;
|
---|
5486 | }
|
---|
5487 | wined3d->adapter_count = 1;
|
---|
5488 |
|
---|
5489 | return WINED3D_OK;
|
---|
5490 | }
|
---|