VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/directx.c@ 23571

Last change on this file since 23571 was 23571, checked in by vboxsync, 15 years ago

crOpenGL: update to wine 1.1.30

  • Property svn:eol-style set to native
File size: 218.0 KB
Line 
1/*
2 * IWineD3D implementation
3 *
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2003-2004 Raphael Junqueira
6 * Copyright 2004 Christian Costa
7 * Copyright 2005 Oliver Stieber
8 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
9 * Copyright 2009 Henri Verbeet for CodeWeavers
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26/*
27 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
28 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
29 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
30 * a choice of LGPL license versions is made available with the language indicating
31 * that LGPLv2 or any later version may be used, or where a choice of which version
32 * of the LGPL is applied is otherwise unspecified.
33 */
34
35#include "config.h"
36#include "wined3d_private.h"
37
38WINE_DEFAULT_DEBUG_CHANNEL(d3d);
39WINE_DECLARE_DEBUG_CHANNEL(d3d_caps);
40
41#define GLINFO_LOCATION (*gl_info)
42
43/* The d3d device ID */
44static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
45
46/* Extension detection */
47static const struct {
48 const char *extension_string;
49 GL_SupportedExt extension;
50 DWORD version;
51} EXTENSION_MAP[] = {
52 /* APPLE */
53 {"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE, 0 },
54 {"GL_APPLE_fence", APPLE_FENCE, 0 },
55 {"GL_APPLE_flush_render", APPLE_FLUSH_RENDER, 0 },
56 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422, 0 },
57 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS, 0 },
58
59 /* ATI */
60 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL, 0 },
61 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3, 0 },
62 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE, 0 },
63 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER, 0 },
64 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC, 0 },
65
66 /* ARB */
67 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT, 0 },
68 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT, 0 },
69 {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP, 0 },
70 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE, 0 },
71 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS, 0 },
72 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM, 0 },
73 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER, 0 },
74 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT, 0 },
75 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4, 0 },
76 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL, 0 },
77 {"GL_ARB_imaging", ARB_IMAGING, 0 },
78 {"GL_ARB_multisample", ARB_MULTISAMPLE, 0 }, /* needs GLX_ARB_MULTISAMPLE as well */
79 {"GL_ARB_multitexture", ARB_MULTITEXTURE, 0 },
80 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY, 0 },
81 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT, 0 },
82 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS, 0 },
83 {"GL_ARB_point_sprite", ARB_POINT_SPRITE, 0 },
84 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX, 0 },
85 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP, 0 },
86 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION, 0 },
87 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP, 0 },
88 {"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD, 0 },
89 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE, 0 },
90 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3, 0 },
91 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT, 0 },
92 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT, 0 },
93 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO, MAKEDWORD_VERSION(2, 0) },
94 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE, 0 },
95 {"GL_ARB_texture_rg", ARB_TEXTURE_RG, 0 },
96 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND, 0 },
97 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT, 0 },
98 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM, 0 },
99 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER, 0 },
100 {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS, 0 },
101 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD, 0 },
102 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX, 0 },
103
104 /* EXT */
105 {"GL_EXT_blend_color", EXT_BLEND_COLOR, 0 },
106 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX, 0 },
107 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE, 0 },
108 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE, 0 },
109 {"GL_EXT_fog_coord", EXT_FOG_COORD, 0 },
110 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT, 0 },
111 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE, 0 },
112 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT, 0 },
113 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL, 0 },
114 {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE, 0 },
115 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS, 0 },
116 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX, 0 },
117 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR, 0 },
118 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE, 0 },
119 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP, 0 },
120 {"GL_EXT_texture3D", EXT_TEXTURE3D, MAKEDWORD_VERSION(1, 2) },
121 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC, 0 },
122 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC, 0 },
123 {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD, 0 },
124 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE, 0 },
125 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3, 0 },
126 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB, 0 },
127 {"GL_EXT_texture_swizzle", EXT_TEXTURE_SWIZZLE, 0 },
128 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC, 0 },
129 {"GL_EXT_texture_lod", EXT_TEXTURE_LOD, 0 },
130 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS, 0 },
131 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA, 0 },
132 {"GL_EXT_vertex_shader", EXT_VERTEX_SHADER, 0 },
133 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS, 0 },
134
135 /* NV */
136 {"GL_NV_half_float", NV_HALF_FLOAT, 0 },
137 {"GL_NV_fence", NV_FENCE, 0 },
138 {"GL_NV_fog_distance", NV_FOG_DISTANCE, 0 },
139 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM, 0 },
140 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2, 0 },
141 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS, 0 },
142 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2, 0 },
143 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION, 0 },
144 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4, 0 },
145 {"GL_NV_texture_shader", NV_TEXTURE_SHADER, 0 },
146 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2, 0 },
147 {"GL_NV_texture_shader3", NV_TEXTURE_SHADER3, 0 },
148 {"GL_NV_occlusion_query", NV_OCCLUSION_QUERY, 0 },
149 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM, 0 },
150 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1, 0 },
151 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2, 0 },
152 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION, 0 },
153 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3, 0 },
154 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION, 0 },
155 {"GL_NV_depth_clamp", NV_DEPTH_CLAMP, 0 },
156 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT, 0 },
157
158 /* SGI */
159 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP, 0 },
160};
161
162/**********************************************************
163 * Utility functions follow
164 **********************************************************/
165
166static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType, WINED3DFORMAT AdapterFormat, DWORD Usage, WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat, WINED3DSURFTYPE SurfaceType);
167static const struct fragment_pipeline *select_fragment_implementation(struct WineD3DAdapter *adapter,
168 WINED3DDEVTYPE DeviceType);
169static const shader_backend_t *select_shader_backend(struct WineD3DAdapter *adapter, WINED3DDEVTYPE DeviceType);
170static const struct blit_shader *select_blit_implementation(struct WineD3DAdapter *adapter, WINED3DDEVTYPE DeviceType);
171
172/* lookup tables */
173const int minLookup[MAX_LOOKUPS] =
174{
175 WINED3DTADDRESS_WRAP, /* WINELOOKUP_WARPPARAM */
176};
177
178const int maxLookup[MAX_LOOKUPS] =
179{
180 WINED3DTADDRESS_MIRRORONCE, /* WINELOOKUP_WARPPARAM */
181};
182
183DWORD *stateLookup[MAX_LOOKUPS];
184
185const struct min_lookup minMipLookup[] =
186{
187 /* NONE POINT LINEAR */
188 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
189 {{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
190 {{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
191};
192
193const struct min_lookup minMipLookup_noFilter[] =
194{
195 /* NONE POINT LINEAR */
196 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
197 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
198 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* LINEAR */
199};
200
201const struct min_lookup minMipLookup_noMip[] =
202{
203 /* NONE POINT LINEAR */
204 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
205 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
206 {{GL_LINEAR, GL_LINEAR, GL_LINEAR }}, /* LINEAR */
207};
208
209const GLenum magLookup[] =
210{
211 /* NONE POINT LINEAR */
212 GL_NEAREST, GL_NEAREST, GL_LINEAR,
213};
214
215const GLenum magLookup_noFilter[] =
216{
217 /* NONE POINT LINEAR */
218 GL_NEAREST, GL_NEAREST, GL_NEAREST,
219};
220
221/* drawStridedSlow attributes */
222glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT];
223glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT];
224glAttribFunc specular_func_3ubv;
225glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT];
226glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT];
227glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT];
228
229/**
230 * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
231 * i.e., there is no GL Context - Get a default rendering context to enable the
232 * function query some info from GL.
233 */
234
235struct wined3d_fake_gl_ctx
236{
237 HDC dc;
238 HWND wnd;
239 HGLRC gl_ctx;
240};
241
242static void WineD3D_ReleaseFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
243{
244 TRACE_(d3d_caps)("Destroying fake GL context.\n");
245
246 if (!pwglMakeCurrent(NULL, NULL))
247 {
248 ERR_(d3d_caps)("Failed to disable fake GL context.\n");
249 }
250
251 if (!pwglDeleteContext(ctx->gl_ctx))
252 {
253 DWORD err = GetLastError();
254 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx->gl_ctx, err);
255 }
256
257 ReleaseDC(ctx->wnd, ctx->dc);
258 DestroyWindow(ctx->wnd);
259}
260
261static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
262{
263 PIXELFORMATDESCRIPTOR pfd;
264 int iPixelFormat;
265
266 TRACE("getting context...\n");
267
268 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
269 ctx->wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
270 WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL);
271 if (!ctx->wnd)
272 {
273 ERR_(d3d_caps)("Failed to create a window.\n");
274 goto fail;
275 }
276
277 ctx->dc = GetDC(ctx->wnd);
278 if (!ctx->dc)
279 {
280 ERR_(d3d_caps)("Failed to get a DC.\n");
281 goto fail;
282 }
283
284 /* PixelFormat selection */
285 ZeroMemory(&pfd, sizeof(pfd));
286 pfd.nSize = sizeof(pfd);
287 pfd.nVersion = 1;
288 pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW; /* PFD_GENERIC_ACCELERATED */
289 pfd.iPixelType = PFD_TYPE_RGBA;
290 pfd.cColorBits = 32;
291 pfd.iLayerType = PFD_MAIN_PLANE;
292
293 iPixelFormat = ChoosePixelFormat(ctx->dc, &pfd);
294 if (!iPixelFormat)
295 {
296 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
297 ERR_(d3d_caps)("Can't find a suitable iPixelFormat.\n");
298 goto fail;
299 }
300 DescribePixelFormat(ctx->dc, iPixelFormat, sizeof(pfd), &pfd);
301 SetPixelFormat(ctx->dc, iPixelFormat, &pfd);
302
303 /* Create a GL context. */
304 ctx->gl_ctx = pwglCreateContext(ctx->dc);
305 if (!ctx->gl_ctx)
306 {
307 WARN_(d3d_caps)("Error creating default context for capabilities initialization.\n");
308 goto fail;
309 }
310
311 /* Make it the current GL context. */
312 if (!context_set_current(NULL))
313 {
314 ERR_(d3d_caps)("Failed to clear current D3D context.\n");
315 }
316
317 if (!pwglMakeCurrent(ctx->dc, ctx->gl_ctx))
318 {
319 ERR_(d3d_caps)("Failed to make fake GL context current.\n");
320 goto fail;
321 }
322
323 return TRUE;
324
325fail:
326 if (ctx->gl_ctx) pwglDeleteContext(ctx->gl_ctx);
327 ctx->gl_ctx = NULL;
328 if (ctx->dc) ReleaseDC(ctx->wnd, ctx->dc);
329 ctx->dc = NULL;
330 if (ctx->wnd) DestroyWindow(ctx->wnd);
331 ctx->wnd = NULL;
332
333 return FALSE;
334}
335
336/* Adjust the amount of used texture memory */
337long WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *D3DDevice, long glram){
338 struct WineD3DAdapter *adapter = D3DDevice->adapter;
339
340 adapter->UsedTextureRam += glram;
341 TRACE("Adjusted gl ram by %ld to %d\n", glram, adapter->UsedTextureRam);
342 return adapter->UsedTextureRam;
343}
344
345/**********************************************************
346 * IUnknown parts follows
347 **********************************************************/
348
349static HRESULT WINAPI IWineD3DImpl_QueryInterface(IWineD3D *iface,REFIID riid,LPVOID *ppobj)
350{
351 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
352
353 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
354 if (IsEqualGUID(riid, &IID_IUnknown)
355 || IsEqualGUID(riid, &IID_IWineD3DBase)
356 || IsEqualGUID(riid, &IID_IWineD3DDevice)) {
357 IUnknown_AddRef(iface);
358 *ppobj = This;
359 return S_OK;
360 }
361 *ppobj = NULL;
362 return E_NOINTERFACE;
363}
364
365static ULONG WINAPI IWineD3DImpl_AddRef(IWineD3D *iface) {
366 IWineD3DImpl *This = (IWineD3DImpl *)iface;
367 ULONG refCount = InterlockedIncrement(&This->ref);
368
369 TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
370 return refCount;
371}
372
373static ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
374 IWineD3DImpl *This = (IWineD3DImpl *)iface;
375 ULONG ref;
376 TRACE("(%p) : Releasing from %d\n", This, This->ref);
377 ref = InterlockedDecrement(&This->ref);
378 if (ref == 0) {
379 unsigned int i;
380
381 for (i = 0; i < This->adapter_count; ++i)
382 {
383 HeapFree(GetProcessHeap(), 0, This->adapters[i].cfgs);
384 }
385 HeapFree(GetProcessHeap(), 0, This);
386 }
387
388 return ref;
389}
390
391/* Set the shader type for this device, depending on the given capabilities
392 * and the user preferences in wined3d_settings. */
393static void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected)
394{
395 if (wined3d_settings.vs_mode == VS_NONE) {
396 *vs_selected = SHADER_NONE;
397 } else if (gl_info->supported[ARB_VERTEX_SHADER] && wined3d_settings.glslRequested) {
398 /* Geforce4 cards support GLSL but for vertex shaders only. Further its reported GLSL caps are
399 * wrong. This combined with the fact that glsl won't offer more features or performance, use ARB
400 * shaders only on this card. */
401 if (gl_info->supported[NV_VERTEX_PROGRAM] && !gl_info->supported[NV_VERTEX_PROGRAM2])
402 *vs_selected = SHADER_ARB;
403 else
404 *vs_selected = SHADER_GLSL;
405 } else if (gl_info->supported[ARB_VERTEX_PROGRAM]) {
406 *vs_selected = SHADER_ARB;
407 } else {
408 *vs_selected = SHADER_NONE;
409 }
410
411 if (wined3d_settings.ps_mode == PS_NONE) {
412 *ps_selected = SHADER_NONE;
413 } else if (gl_info->supported[ARB_FRAGMENT_SHADER] && wined3d_settings.glslRequested) {
414 *ps_selected = SHADER_GLSL;
415 } else if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) {
416 *ps_selected = SHADER_ARB;
417 } else if (gl_info->supported[ATI_FRAGMENT_SHADER]) {
418 *ps_selected = SHADER_ATI;
419 } else {
420 *ps_selected = SHADER_NONE;
421 }
422}
423
424/** Select the number of report maximum shader constants based on the selected shader modes */
425static void select_shader_max_constants(int ps_selected_mode, int vs_selected_mode, struct wined3d_gl_info *gl_info)
426{
427 switch (vs_selected_mode) {
428 case SHADER_GLSL:
429 gl_info->max_vshader_constantsF = gl_info->vs_glsl_constantsF;
430 break;
431 case SHADER_ARB:
432 gl_info->max_vshader_constantsF = gl_info->vs_arb_constantsF;
433 break;
434 default:
435 gl_info->max_vshader_constantsF = 0;
436 break;
437 }
438
439 switch (ps_selected_mode) {
440 case SHADER_GLSL:
441 gl_info->max_pshader_constantsF = gl_info->ps_glsl_constantsF;
442 break;
443 case SHADER_ARB:
444 gl_info->max_pshader_constantsF = gl_info->ps_arb_constantsF;
445 break;
446 default:
447 gl_info->max_pshader_constantsF = 0;
448 break;
449 }
450}
451
452/**********************************************************
453 * IWineD3D parts follows
454 **********************************************************/
455
456/* GL locking is done by the caller */
457static inline BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
458{
459 GLuint prog;
460 BOOL ret = FALSE;
461 const char *testcode =
462 "!!ARBvp1.0\n"
463 "PARAM C[66] = { program.env[0..65] };\n"
464 "ADDRESS A0;"
465 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
466 "ARL A0.x, zero.x;\n"
467 "MOV result.position, C[A0.x + 65];\n"
468 "END\n";
469
470 while(glGetError());
471 GL_EXTCALL(glGenProgramsARB(1, &prog));
472 if(!prog) {
473 ERR("Failed to create an ARB offset limit test program\n");
474 }
475 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
476 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
477 strlen(testcode), testcode));
478 if(glGetError() != 0) {
479 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
480 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
481 ret = TRUE;
482 } else TRACE("OpenGL implementation allows offsets > 63\n");
483
484 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
485 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
486 checkGLcall("ARB vp offset limit test cleanup");
487
488 return ret;
489}
490
491static DWORD ver_for_ext(GL_SupportedExt ext)
492{
493 unsigned int i;
494 for (i = 0; i < (sizeof(EXTENSION_MAP) / sizeof(*EXTENSION_MAP)); ++i) {
495 if(EXTENSION_MAP[i].extension == ext) {
496 return EXTENSION_MAP[i].version;
497 }
498 }
499 return 0;
500}
501
502static BOOL match_ati_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer)
503{
504 if (gl_info->gl_vendor != VENDOR_ATI) return FALSE;
505 if (gl_info->gl_card == CARD_ATI_RADEON_9500) return TRUE;
506 if (gl_info->gl_card == CARD_ATI_RADEON_X700) return TRUE;
507 if (gl_info->gl_card == CARD_ATI_RADEON_X1600) return TRUE;
508 return FALSE;
509}
510
511static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl_renderer)
512{
513 if (gl_info->gl_vendor == VENDOR_NVIDIA)
514 {
515 if (gl_info->gl_card == CARD_NVIDIA_GEFORCEFX_5800 || gl_info->gl_card == CARD_NVIDIA_GEFORCEFX_5600)
516 {
517 return TRUE;
518 }
519 }
520 return FALSE;
521}
522
523static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_renderer)
524{
525 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
526 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
527 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
528 *
529 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
530 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
531 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
532 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
533 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
534 * the chance that other implementations support them is rather small since Win32 QuickTime uses
535 * DirectDraw, not OpenGL. */
536 if (gl_info->supported[APPLE_FENCE]
537 && gl_info->supported[APPLE_CLIENT_STORAGE]
538 && gl_info->supported[APPLE_FLUSH_RENDER]
539 && gl_info->supported[APPLE_YCBCR_422])
540 {
541 return TRUE;
542 }
543 else
544 {
545 return FALSE;
546 }
547}
548
549/* Context activation is done by the caller. */
550static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
551{
552 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
553 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
554 * all the texture. This function detects this bug by its symptom and disables PBOs
555 * if the test fails.
556 *
557 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
558 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
559 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
560 * read back is compared to the original. If they are equal PBOs are assumed to work,
561 * otherwise the PBO extension is disabled. */
562 GLuint texture, pbo;
563 static const unsigned int pattern[] =
564 {
565 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
566 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
567 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
568 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
569 };
570 unsigned int check[sizeof(pattern) / sizeof(pattern[0])];
571
572 /* No PBO -> No point in testing them. */
573 if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
574
575 ENTER_GL();
576
577 while (glGetError());
578 glGenTextures(1, &texture);
579 glBindTexture(GL_TEXTURE_2D, texture);
580
581 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
582 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0);
583 checkGLcall("Specifying the PBO test texture");
584
585 GL_EXTCALL(glGenBuffersARB(1, &pbo));
586 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo));
587 GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, sizeof(pattern), pattern, GL_STREAM_DRAW_ARB));
588 checkGLcall("Specifying the PBO test pbo");
589
590 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
591 checkGLcall("Loading the PBO test texture");
592
593 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
594 wglFinish(); /* just to be sure */
595
596 memset(check, 0, sizeof(check));
597 glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
598 checkGLcall("Reading back the PBO test texture");
599
600 glDeleteTextures(1, &texture);
601 GL_EXTCALL(glDeleteBuffersARB(1, &pbo));
602 checkGLcall("PBO test cleanup");
603
604 LEAVE_GL();
605
606 if (memcmp(check, pattern, sizeof(check)))
607 {
608 WARN_(d3d_caps)("PBO test failed, read back data doesn't match original.\n");
609 WARN_(d3d_caps)("Disabling PBOs. This may result in slower performance.\n");
610 gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] = FALSE;
611 }
612 else
613 {
614 TRACE_(d3d_caps)("PBO test successful.\n");
615 }
616}
617
618static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer)
619{
620 return gl_info->gl_vendor == VENDOR_INTEL && match_apple(gl_info, gl_renderer);
621}
622
623static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, const char *gl_renderer)
624{
625 if (!match_apple(gl_info, gl_renderer)) return FALSE;
626 if (gl_info->gl_vendor != VENDOR_ATI) return FALSE;
627 if (gl_info->gl_card == CARD_ATI_RADEON_X1600) return FALSE;
628 return TRUE;
629}
630
631static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, const char *gl_renderer)
632{
633 if (gl_info->gl_vendor != VENDOR_ATI) return FALSE;
634 if (match_apple(gl_info, gl_renderer)) return FALSE;
635 if (strstr(gl_renderer, "DRI")) return FALSE; /* Filter out Mesa DRI drivers. */
636 return TRUE;
637}
638
639static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer)
640{
641 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
642 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
643 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
644 * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
645 * hardcoded
646 *
647 * dx10 cards usually have 64 varyings */
648 return gl_info->max_glsl_varyings > 44;
649}
650
651/* A GL context is provided by the caller */
652static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const char *gl_renderer)
653{
654 GLenum error;
655 DWORD data[16];
656
657 if(!GL_SUPPORT(EXT_SECONDARY_COLOR)) return FALSE;
658
659 ENTER_GL();
660 while(glGetError());
661 GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
662 error = glGetError();
663 LEAVE_GL();
664
665 if(error == GL_NO_ERROR)
666 {
667 TRACE("GL Implementation accepts 4 component specular color pointers\n");
668 return TRUE;
669 }
670 else
671 {
672 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
673 debug_glerror(error));
674 return FALSE;
675 }
676}
677
678static void quirk_arb_constants(struct wined3d_gl_info *gl_info)
679{
680 TRACE_(d3d_caps)("Using ARB vs constant limit(=%u) for GLSL.\n", gl_info->vs_arb_constantsF);
681 gl_info->vs_glsl_constantsF = gl_info->vs_arb_constantsF;
682 TRACE_(d3d_caps)("Using ARB ps constant limit(=%u) for GLSL.\n", gl_info->ps_arb_constantsF);
683 gl_info->ps_glsl_constantsF = gl_info->ps_arb_constantsF;
684}
685
686static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
687{
688 quirk_arb_constants(gl_info);
689 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
690 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
691 * allow 48 different offsets or other helper immediate values. */
692 TRACE_(d3d_caps)("Reserving 12 GLSL constants for compiler private use.\n");
693 gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 12);
694}
695
696/* fglrx crashes with a very bad kernel panic if GL_POINT_SPRITE_ARB is set to GL_COORD_REPLACE_ARB
697 * on more than one texture unit. This means that the d3d9 visual point size test will cause a
698 * kernel panic on any machine running fglrx 9.3(latest that supports r300 to r500 cards). This
699 * quirk only enables point sprites on the first texture unit. This keeps point sprites working in
700 * most games, but avoids the crash
701 *
702 * A more sophisticated way would be to find all units that need texture coordinates and enable
703 * point sprites for one if only one is found, and software emulate point sprites in drawStridedSlow
704 * if more than one unit needs texture coordinates(This requires software ffp and vertex shaders though)
705 *
706 * Note that disabling the extension entirely does not gain predictability because there is no point
707 * sprite capability flag in d3d, so the potential rendering bugs are the same if we disable the extension. */
708static void quirk_one_point_sprite(struct wined3d_gl_info *gl_info)
709{
710 if (gl_info->supported[ARB_POINT_SPRITE])
711 {
712 TRACE("Limiting point sprites to one texture unit.\n");
713 gl_info->max_point_sprite_units = 1;
714 }
715}
716
717static void quirk_ati_dx9(struct wined3d_gl_info *gl_info)
718{
719 quirk_arb_constants(gl_info);
720
721 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
722 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
723 * If real NP2 textures are used, the driver falls back to software. We could just remove the
724 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconventient
725 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
726 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
727 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
728 *
729 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
730 * has this extension promoted to core. The extension loading code sets this extension supported
731 * due to that, so this code works on fglrx as well. */
732 if(gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
733 {
734 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
735 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
736 gl_info->supported[WINE_NORMALIZED_TEXRECT] = TRUE;
737 }
738
739 /* fglrx has the same structural issues as the one described in quirk_apple_glsl_constants, although
740 * it is generally more efficient. Reserve just 8 constants. */
741 TRACE_(d3d_caps)("Reserving 8 GLSL constants for compiler private use.\n");
742 gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 8);
743}
744
745static void quirk_no_np2(struct wined3d_gl_info *gl_info)
746{
747 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
748 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
749 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
750 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
751 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
752 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
753 *
754 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
755 * triggering the software fallback. There is not much we can do here apart from disabling the
756 * software-emulated extension and reenable ARB_tex_rect (which was previously disabled
757 * in IWineD3DImpl_FillGLCaps).
758 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
759 * post-processing effects in the game "Max Payne 2").
760 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
761 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
762 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
763 gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE;
764}
765
766static void quirk_texcoord_w(struct wined3d_gl_info *gl_info)
767{
768 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
769 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
770 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
771 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
772 * according to the spec.
773 *
774 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
775 * makes the shader slower and eats instruction slots which should be available to the d3d app.
776 *
777 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
778 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
779 * this workaround is activated on cards that do not need it, it won't break things, just affect
780 * performance negatively. */
781 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
782 gl_info->quirks |= WINED3D_QUIRK_SET_TEXCOORD_W;
783}
784
785static void quirk_clip_varying(struct wined3d_gl_info *gl_info)
786{
787 gl_info->quirks |= WINED3D_QUIRK_GLSL_CLIP_VARYING;
788}
789
790static void quirk_allows_specular_alpha(struct wined3d_gl_info *gl_info)
791{
792 gl_info->quirks |= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA;
793}
794
795struct driver_quirk
796{
797 BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer);
798 void (*apply)(struct wined3d_gl_info *gl_info);
799 const char *description;
800};
801
802static const struct driver_quirk quirk_table[] =
803{
804 {
805 match_ati_r300_to_500,
806 quirk_ati_dx9,
807 "ATI GLSL constant and normalized texrect quirk"
808 },
809 /* MacOS advertises more GLSL vertex shader uniforms than supported by the hardware, and if more are
810 * used it falls back to software. While the compiler can detect if the shader uses all declared
811 * uniforms, the optimization fails if the shader uses relative addressing. So any GLSL shader
812 * using relative addressing falls back to software.
813 *
814 * ARB vp gives the correct amount of uniforms, so use it instead of GLSL. */
815 {
816 match_apple,
817 quirk_apple_glsl_constants,
818 "Apple GLSL uniform override"
819 },
820 {
821 match_geforce5,
822 quirk_no_np2,
823 "Geforce 5 NP2 disable"
824 },
825 {
826 match_apple_intel,
827 quirk_texcoord_w,
828 "Init texcoord .w for Apple Intel GPU driver"
829 },
830 {
831 match_apple_nonr500ati,
832 quirk_texcoord_w,
833 "Init texcoord .w for Apple ATI >= r600 GPU driver"
834 },
835 {
836 match_fglrx,
837 quirk_one_point_sprite,
838 "Fglrx point sprite crash workaround"
839 },
840 {
841 match_dx10_capable,
842 quirk_clip_varying,
843 "Reserved varying for gl_ClipPos"
844 },
845 {
846 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
847 * GL implementations accept it. The Mac GL is the only implementation known to
848 * reject it.
849 *
850 * If we can pass 4 component specular colors, do it, because (a) we don't have
851 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
852 * passes specular alpha to the pixel shader if any is used. Otherwise the
853 * specular alpha is used to pass the fog coordinate, which we pass to opengl
854 * via GL_EXT_fog_coord.
855 */
856 match_allows_spec_alpha,
857 quirk_allows_specular_alpha,
858 "Allow specular alpha quirk"
859 }
860};
861
862/* Certain applications (Steam) complain if we report an outdated driver version. In general,
863 * reporting a driver version is moot because we are not the Windows driver, and we have different
864 * bugs, features, etc.
865 *
866 * If a card is not found in this table, the GL driver version is reported. */
867struct driver_version_information
868{
869 WORD vendor; /* reported PCI card vendor ID */
870 WORD card; /* reported PCI card device ID */
871 const char *description; /* Description of the card e.g. NVIDIA RIVA TNT */
872 WORD hipart_hi, hipart_lo; /* driver hiword to report */
873 WORD lopart_hi, lopart_lo; /* driver loword to report */
874};
875
876static const struct driver_version_information driver_version_table[] =
877{
878 /* Nvidia drivers. Geforce6 and newer cards are supported by the current driver (180.x)
879 * GeforceFX support is up to 173.x, - driver uses numbering x.y.11.7341 for 173.41 where x is the windows revision (6=2000/xp, 7=vista), y is unknown
880 * Geforce2MX/3/4 up to 96.x - driver uses numbering 9.6.8.9 for 96.89
881 * TNT/Geforce1/2 up to 71.x - driver uses numbering 7.1.8.6 for 71.86
882 *
883 * All version numbers used below are from the Linux nvidia drivers. */
884 {VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", 7, 1, 8, 6 },
885 {VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", 7, 1, 8, 6 },
886 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", 7, 1, 8, 6 },
887 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", 9, 6, 4, 3 },
888 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", 7, 1, 8, 6 },
889 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", 9, 6, 10, 9371 },
890 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", 9, 6, 10, 9371 },
891 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", 9, 6, 10, 9371 },
892 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", 7, 15, 11, 7516 },
893 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", 7, 15, 11, 7516 },
894 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", 7, 15, 11, 7516 },
895 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", 7, 15, 11, 8618 },
896 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", 7, 15, 11, 8618 },
897 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", 7, 15, 11, 8618 },
898 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", 7, 15, 11, 8585 },
899 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", 7, 15, 11, 8585 },
900 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", 7, 15, 11, 8618 },
901 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", 7, 15, 11, 8618 },
902 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", 7, 15, 11, 8618 },
903 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", 7, 15, 11, 8618 },
904 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", 7, 15, 11, 8585 },
905 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", 7, 15, 11, 8618 },
906 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", 7, 15, 11, 8618 },
907 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", 7, 15, 11, 8618 },
908 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", 7, 15, 11, 8618 },
909 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", 7, 15, 11, 8618 },
910 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", 7, 15, 11, 8618 },
911 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", 7, 15, 11, 8618 },
912 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", 7, 15, 11, 8618 },
913 {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", 7, 15, 11, 8618 },
914
915 /* ATI cards. The driver versions are somewhat similar, but not quite the same. Let's hardcode. */
916 {VENDOR_ATI, CARD_ATI_RADEON_9500, "ATI Radeon 9500", 6, 14, 10, 6764 },
917 {VENDOR_ATI, CARD_ATI_RADEON_X700, "ATI Radeon X700 SE", 6, 14, 10, 6764 },
918 {VENDOR_ATI, CARD_ATI_RADEON_X1600, "ATI Radeon X1600 Series", 6, 14, 10, 6764 },
919 {VENDOR_ATI, CARD_ATI_RADEON_HD2300, "ATI Mobility Radeon HD 2300", 6, 14, 10, 6764 },
920 {VENDOR_ATI, CARD_ATI_RADEON_HD2600, "ATI Mobility Radeon HD 2600", 6, 14, 10, 6764 },
921 {VENDOR_ATI, CARD_ATI_RADEON_HD2900, "ATI Radeon HD 2900 XT", 6, 14, 10, 6764 },
922 {VENDOR_ATI, CARD_ATI_RADEON_HD4350, "ATI Radeon HD 4350", 6, 14, 10, 6764 },
923 {VENDOR_ATI, CARD_ATI_RADEON_HD4600, "ATI Radeon HD 4600 Series", 6, 14, 10, 6764 },
924 {VENDOR_ATI, CARD_ATI_RADEON_HD4700, "ATI Radeon HD 4700 Series", 6, 14, 10, 6764 },
925 {VENDOR_ATI, CARD_ATI_RADEON_HD4800, "ATI Radeon HD 4800 Series", 6, 14, 10, 6764 },
926
927 /* TODO: Add information about legacy ATI hardware, Intel and other cards. */
928};
929
930/* Context activation is done by the caller. */
931static void fixup_extensions(struct wined3d_gl_info *gl_info, const char *gl_renderer)
932{
933 unsigned int i;
934
935 for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i)
936 {
937 if (!quirk_table[i].match(gl_info, gl_renderer)) continue;
938 TRACE_(d3d_caps)("Applying driver quirk \"%s\".\n", quirk_table[i].description);
939 quirk_table[i].apply(gl_info);
940 }
941
942 /* Find out if PBOs work as they are supposed to. */
943 test_pbo_functionality(gl_info);
944
945 /* Fixup the driver version we'll report to the app. */
946 gl_info->driver_version = MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
947 gl_info->driver_version_hipart = MAKEDWORD_VERSION(7, 1);
948 for (i = 0; i < (sizeof(driver_version_table) / sizeof(driver_version_table[0])); ++i)
949 {
950 if (gl_info->gl_vendor == driver_version_table[i].vendor
951 && gl_info->gl_card == driver_version_table[i].card)
952 {
953 TRACE_(d3d_caps)("Found card 0x%04x, 0x%04x in driver version DB.\n",
954 gl_info->gl_vendor, gl_info->gl_card);
955
956 gl_info->driver_version = MAKEDWORD_VERSION(driver_version_table[i].lopart_hi,
957 driver_version_table[i].lopart_lo);
958 gl_info->driver_version_hipart = MAKEDWORD_VERSION(driver_version_table[i].hipart_hi,
959 driver_version_table[i].hipart_lo);
960 gl_info->driver_description = driver_version_table[i].description;
961 break;
962 }
963 }
964 TRACE_(d3d_caps)("Reporting (fake) driver version 0x%08X-0x%08X.\n",
965 gl_info->driver_version_hipart, gl_info->driver_version);
966}
967
968static DWORD wined3d_parse_gl_version(const char *gl_version)
969{
970 const char *ptr = gl_version;
971 int major, minor;
972
973 major = atoi(ptr);
974 if (major <= 0) ERR_(d3d_caps)("Invalid opengl major version: %d.\n", major);
975
976 while (isdigit(*ptr)) ++ptr;
977 if (*ptr++ != '.') ERR_(d3d_caps)("Invalid opengl version string: %s.\n", debugstr_a(gl_version));
978
979 minor = atoi(ptr);
980
981 TRACE_(d3d_caps)("Found OpenGL version: %d.%d.\n", major, minor);
982
983 return MAKEDWORD_VERSION(major, minor);
984}
985
986static GL_Vendors wined3d_guess_vendor(const char *gl_vendor, const char *gl_renderer)
987{
988 if (strstr(gl_vendor, "NVIDIA"))
989 return VENDOR_NVIDIA;
990
991 if (strstr(gl_vendor, "ATI"))
992 return VENDOR_ATI;
993
994 if (strstr(gl_vendor, "Intel(R)")
995 || strstr(gl_renderer, "Intel(R)")
996 || strstr(gl_vendor, "Intel Inc."))
997 return VENDOR_INTEL;
998
999 if (strstr(gl_vendor, "Mesa")
1000 || strstr(gl_vendor, "DRI R300 Project")
1001 || strstr(gl_vendor, "Tungsten Graphics, Inc"))
1002 return VENDOR_MESA;
1003
1004 FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning VENDOR_WINE.\n", debugstr_a(gl_vendor));
1005
1006 return VENDOR_WINE;
1007}
1008
1009static GL_Cards wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
1010 GL_Vendors *vendor, unsigned int *vidmem)
1011{
1012 /* Below is a list of Nvidia and ATI GPUs. Both vendors have dozens of
1013 * different GPUs with roughly the same features. In most cases GPUs from a
1014 * certain family differ in clockspeeds, the amount of video memory and the
1015 * number of shader pipelines.
1016 *
1017 * A Direct3D device object contains the PCI id (vendor + device) of the
1018 * videocard which is used for rendering. Various applications use this
1019 * information to get a rough estimation of the features of the card and
1020 * some might use it for enabling 3d effects only on certain types of
1021 * videocards. In some cases games might even use it to work around bugs
1022 * which happen on certain videocards/driver combinations. The problem is
1023 * that OpenGL only exposes a rendering string containing the name of the
1024 * videocard and not the PCI id.
1025 *
1026 * Various games depend on the PCI id, so somehow we need to provide one.
1027 * A simple option is to parse the renderer string and translate this to
1028 * the right PCI id. This is a lot of work because there are more than 200
1029 * GPUs just for Nvidia. Various cards share the same renderer string, so
1030 * the amount of code might be 'small' but there are quite a number of
1031 * exceptions which would make this a pain to maintain. Another way would
1032 * be to query the PCI id from the operating system (assuming this is the
1033 * videocard which is used for rendering which is not always the case).
1034 * This would work but it is not very portable. Second it would not work
1035 * well in, let's say, a remote X situation in which the amount of 3d
1036 * features which can be used is limited.
1037 *
1038 * As said most games only use the PCI id to get an indication of the
1039 * capabilities of the card. It doesn't really matter if the given id is
1040 * the correct one if we return the id of a card with similar 3d features.
1041 *
1042 * The code below checks the OpenGL capabilities of a videocard and matches
1043 * that to a certain level of Direct3D functionality. Once a card passes
1044 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
1045 * least a GeforceFX. To give a better estimate we do a basic check on the
1046 * renderer string but if that won't pass we return a default card. This
1047 * way is better than maintaining a full card database as even without a
1048 * full database we can return a card with similar features. Second the
1049 * size of the database can be made quite small because when you know what
1050 * type of 3d functionality a card has, you know to which GPU family the
1051 * GPU must belong. Because of this you only have to check a small part of
1052 * the renderer string to distinguishes between different models from that
1053 * family.
1054 *
1055 * The code also selects a default amount of video memory which we will
1056 * use for an estimation of the amount of free texture memory. In case of
1057 * real D3D the amount of texture memory includes video memory and system
1058 * memory (to be specific AGP memory or in case of PCIE TurboCache /
1059 * HyperMemory). We don't know how much system memory can be addressed by
1060 * the system but we can make a reasonable estimation about the amount of
1061 * video memory. If the value is slightly wrong it doesn't matter as we
1062 * didn't include AGP-like memory which makes the amount of addressable
1063 * memory higher and second OpenGL isn't that critical it moves to system
1064 * memory behind our backs if really needed. Note that the amount of video
1065 * memory can be overruled using a registry setting. */
1066
1067 switch (*vendor)
1068 {
1069 case VENDOR_NVIDIA:
1070 /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
1071 * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
1072 */
1073 if (WINE_D3D9_CAPABLE(gl_info) && gl_info->supported[NV_VERTEX_PROGRAM3])
1074 {
1075 /* Geforce 200 - highend */
1076 if (strstr(gl_renderer, "GTX 280")
1077 || strstr(gl_renderer, "GTX 285")
1078 || strstr(gl_renderer, "GTX 295"))
1079 {
1080 *vidmem = 1024;
1081 return CARD_NVIDIA_GEFORCE_GTX280;
1082 }
1083
1084 /* Geforce 200 - midend high */
1085 if (strstr(gl_renderer, "GTX 275"))
1086 {
1087 *vidmem = 896;
1088 return CARD_NVIDIA_GEFORCE_GTX275;
1089 }
1090
1091 /* Geforce 200 - midend */
1092 if (strstr(gl_renderer, "GTX 260"))
1093 {
1094 *vidmem = 1024;
1095 return CARD_NVIDIA_GEFORCE_GTX260;
1096 }
1097
1098 /* Geforce9 - highend / Geforce 200 - midend (GTS 150/250 are based on the same core) */
1099 if (strstr(gl_renderer, "9800")
1100 || strstr(gl_renderer, "GTS 150")
1101 || strstr(gl_renderer, "GTS 250"))
1102 {
1103 *vidmem = 512;
1104 return CARD_NVIDIA_GEFORCE_9800GT;
1105 }
1106
1107 /* Geforce9 - midend */
1108 if (strstr(gl_renderer, "9600"))
1109 {
1110 *vidmem = 384; /* The 9600GSO has 384MB, the 9600GT has 512-1024MB */
1111 return CARD_NVIDIA_GEFORCE_9600GT;
1112 }
1113
1114 /* Geforce9 - midend low / Geforce 200 - low */
1115 if (strstr(gl_renderer, "9500")
1116 || strstr(gl_renderer, "GT 120")
1117 || strstr(gl_renderer, "GT 130"))
1118 {
1119 *vidmem = 256; /* The 9500GT has 256-1024MB */
1120 return CARD_NVIDIA_GEFORCE_9500GT;
1121 }
1122
1123 /* Geforce9 - lowend */
1124 if (strstr(gl_renderer, "9400"))
1125 {
1126 *vidmem = 256; /* The 9400GT has 256-1024MB */
1127 return CARD_NVIDIA_GEFORCE_9400GT;
1128 }
1129
1130 /* Geforce9 - lowend low */
1131 if (strstr(gl_renderer, "9100")
1132 || strstr(gl_renderer, "9200")
1133 || strstr(gl_renderer, "9300")
1134 || strstr(gl_renderer, "G 100"))
1135 {
1136 *vidmem = 256; /* The 9100-9300 cards have 256MB */
1137 return CARD_NVIDIA_GEFORCE_9200;
1138 }
1139
1140 /* Geforce8 - highend */
1141 if (strstr(gl_renderer, "8800"))
1142 {
1143 *vidmem = 320; /* The 8800GTS uses 320MB, a 8800GTX can have 768MB */
1144 return CARD_NVIDIA_GEFORCE_8800GTS;
1145 }
1146
1147 /* Geforce8 - midend mobile */
1148 if (strstr(gl_renderer, "8600 M"))
1149 {
1150 *vidmem = 512;
1151 return CARD_NVIDIA_GEFORCE_8600MGT;
1152 }
1153
1154 /* Geforce8 - midend */
1155 if (strstr(gl_renderer, "8600")
1156 || strstr(gl_renderer, "8700"))
1157 {
1158 *vidmem = 256;
1159 return CARD_NVIDIA_GEFORCE_8600GT;
1160 }
1161
1162 /* Geforce8 - lowend */
1163 if (strstr(gl_renderer, "8300")
1164 || strstr(gl_renderer, "8400")
1165 || strstr(gl_renderer, "8500"))
1166 {
1167 *vidmem = 128; /* 128-256MB for a 8300, 256-512MB for a 8400 */
1168 return CARD_NVIDIA_GEFORCE_8300GS;
1169 }
1170
1171 /* Geforce7 - highend */
1172 if (strstr(gl_renderer, "7800")
1173 || strstr(gl_renderer, "7900")
1174 || strstr(gl_renderer, "7950")
1175 || strstr(gl_renderer, "Quadro FX 4")
1176 || strstr(gl_renderer, "Quadro FX 5"))
1177 {
1178 *vidmem = 256; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */
1179 return CARD_NVIDIA_GEFORCE_7800GT;
1180 }
1181
1182 /* Geforce7 midend */
1183 if (strstr(gl_renderer, "7600")
1184 || strstr(gl_renderer, "7700"))
1185 {
1186 *vidmem = 256; /* The 7600 uses 256-512MB */
1187 return CARD_NVIDIA_GEFORCE_7600;
1188 }
1189
1190 /* Geforce7 lower medium */
1191 if (strstr(gl_renderer, "7400"))
1192 {
1193 *vidmem = 256; /* The 7400 uses 256-512MB */
1194 return CARD_NVIDIA_GEFORCE_7400;
1195 }
1196
1197 /* Geforce7 lowend */
1198 if (strstr(gl_renderer, "7300"))
1199 {
1200 *vidmem = 256; /* Mac Pros with this card have 256 MB */
1201 return CARD_NVIDIA_GEFORCE_7300;
1202 }
1203
1204 /* Geforce6 highend */
1205 if (strstr(gl_renderer, "6800"))
1206 {
1207 *vidmem = 128; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */
1208 return CARD_NVIDIA_GEFORCE_6800;
1209 }
1210
1211 /* Geforce6 - midend */
1212 if (strstr(gl_renderer, "6600")
1213 || strstr(gl_renderer, "6610")
1214 || strstr(gl_renderer, "6700"))
1215 {
1216 *vidmem = 128; /* A 6600GT has 128-256MB */
1217 return CARD_NVIDIA_GEFORCE_6600GT;
1218 }
1219
1220 /* Geforce6/7 lowend */
1221 *vidmem = 64; /* */
1222 return CARD_NVIDIA_GEFORCE_6200; /* Geforce 6100/6150/6200/7300/7400/7500 */
1223 }
1224
1225 if (WINE_D3D9_CAPABLE(gl_info))
1226 {
1227 /* GeforceFX - highend */
1228 if (strstr(gl_renderer, "5800")
1229 || strstr(gl_renderer, "5900")
1230 || strstr(gl_renderer, "5950")
1231 || strstr(gl_renderer, "Quadro FX"))
1232 {
1233 *vidmem = 256; /* 5800-5900 cards use 256MB */
1234 return CARD_NVIDIA_GEFORCEFX_5800;
1235 }
1236
1237 /* GeforceFX - midend */
1238 if (strstr(gl_renderer, "5600")
1239 || strstr(gl_renderer, "5650")
1240 || strstr(gl_renderer, "5700")
1241 || strstr(gl_renderer, "5750"))
1242 {
1243 *vidmem = 128; /* A 5600 uses 128-256MB */
1244 return CARD_NVIDIA_GEFORCEFX_5600;
1245 }
1246
1247 /* GeforceFX - lowend */
1248 *vidmem = 64; /* Normal FX5200 cards use 64-256MB; laptop (non-standard) can have less */
1249 return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */
1250 }
1251
1252 if (WINE_D3D8_CAPABLE(gl_info))
1253 {
1254 if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4"))
1255 {
1256 *vidmem = 64; /* Geforce4 Ti cards have 64-128MB */
1257 return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
1258 }
1259
1260 *vidmem = 64; /* Geforce3 cards have 64-128MB */
1261 return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
1262 }
1263
1264 if (WINE_D3D7_CAPABLE(gl_info))
1265 {
1266 if (strstr(gl_renderer, "GeForce4 MX"))
1267 {
1268 /* Most Geforce4MX GPUs have at least 64MB of memory, some
1269 * early models had 32MB but most have 64MB or even 128MB. */
1270 *vidmem = 64;
1271 return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */
1272 }
1273
1274 if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR"))
1275 {
1276 *vidmem = 32; /* Geforce2MX GPUs have 32-64MB of video memory */
1277 return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
1278 }
1279
1280 if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2"))
1281 {
1282 *vidmem = 32; /* Geforce2 GPUs have 32-64MB of video memory */
1283 return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
1284 }
1285
1286 /* Most Geforce1 cards have 32MB, there are also some rare 16
1287 * and 64MB (Dell) models. */
1288 *vidmem = 32;
1289 return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */
1290 }
1291
1292 if (strstr(gl_renderer, "TNT2"))
1293 {
1294 *vidmem = 32; /* Most TNT2 boards have 32MB, though there are 16MB boards too */
1295 return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */
1296 }
1297
1298 *vidmem = 16; /* Most TNT boards have 16MB, some rare models have 8MB */
1299 return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */
1300
1301 case VENDOR_ATI:
1302 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1303 *
1304 * Beware: renderer string do not match exact card model,
1305 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1306 if (WINE_D3D9_CAPABLE(gl_info))
1307 {
1308 /* Radeon R7xx HD4800 - highend */
1309 if (strstr(gl_renderer, "HD 4800") /* Radeon RV7xx HD48xx generic renderer string */
1310 || strstr(gl_renderer, "HD 4830") /* Radeon RV770 */
1311 || strstr(gl_renderer, "HD 4850") /* Radeon RV770 */
1312 || strstr(gl_renderer, "HD 4870") /* Radeon RV770 */
1313 || strstr(gl_renderer, "HD 4890")) /* Radeon RV790 */
1314 {
1315 *vidmem = 512; /* note: HD4890 cards use 1024MB */
1316 return CARD_ATI_RADEON_HD4800;
1317 }
1318
1319 /* Radeon R740 HD4700 - midend */
1320 if (strstr(gl_renderer, "HD 4700") /* Radeon RV770 */
1321 || strstr(gl_renderer, "HD 4770")) /* Radeon RV740 */
1322 {
1323 *vidmem = 512;
1324 return CARD_ATI_RADEON_HD4700;
1325 }
1326
1327 /* Radeon R730 HD4600 - midend */
1328 if (strstr(gl_renderer, "HD 4600") /* Radeon RV730 */
1329 || strstr(gl_renderer, "HD 4650") /* Radeon RV730 */
1330 || strstr(gl_renderer, "HD 4670")) /* Radeon RV730 */
1331 {
1332 *vidmem = 512;
1333 return CARD_ATI_RADEON_HD4600;
1334 }
1335
1336 /* Radeon R710 HD4500/HD4350 - lowend */
1337 if (strstr(gl_renderer, "HD 4350") /* Radeon RV710 */
1338 || strstr(gl_renderer, "HD 4550")) /* Radeon RV710 */
1339 {
1340 *vidmem = 256;
1341 return CARD_ATI_RADEON_HD4350;
1342 }
1343
1344 /* Radeon R6xx HD2900/HD3800 - highend */
1345 if (strstr(gl_renderer, "HD 2900")
1346 || strstr(gl_renderer, "HD 3870")
1347 || strstr(gl_renderer, "HD 3850"))
1348 {
1349 *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
1350 return CARD_ATI_RADEON_HD2900;
1351 }
1352
1353 /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
1354 if (strstr(gl_renderer, "HD 2600")
1355 || strstr(gl_renderer, "HD 3830")
1356 || strstr(gl_renderer, "HD 3690")
1357 || strstr(gl_renderer, "HD 3650"))
1358 {
1359 *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
1360 return CARD_ATI_RADEON_HD2600;
1361 }
1362
1363 /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */
1364 if (strstr(gl_renderer, "HD 2300")
1365 || strstr(gl_renderer, "HD 2400")
1366 || strstr(gl_renderer, "HD 3470")
1367 || strstr(gl_renderer, "HD 3450")
1368 || strstr(gl_renderer, "HD 3430")
1369 || strstr(gl_renderer, "HD 3400"))
1370 {
1371 *vidmem = 128; /* HD2300 uses at least 128MB, HD2400 uses 256MB */
1372 return CARD_ATI_RADEON_HD2300;
1373 }
1374
1375 /* Radeon R6xx/R7xx integrated */
1376 if (strstr(gl_renderer, "HD 3100")
1377 || strstr(gl_renderer, "HD 3200")
1378 || strstr(gl_renderer, "HD 3300"))
1379 {
1380 *vidmem = 128; /* 128MB */
1381 return CARD_ATI_RADEON_HD3200;
1382 }
1383
1384 /* Radeon R5xx */
1385 if (strstr(gl_renderer, "X1600")
1386 || strstr(gl_renderer, "X1650")
1387 || strstr(gl_renderer, "X1800")
1388 || strstr(gl_renderer, "X1900")
1389 || strstr(gl_renderer, "X1950"))
1390 {
1391 *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */
1392 return CARD_ATI_RADEON_X1600;
1393 }
1394
1395 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */
1396 if (strstr(gl_renderer, "X700")
1397 || strstr(gl_renderer, "X800")
1398 || strstr(gl_renderer, "X850")
1399 || strstr(gl_renderer, "X1300")
1400 || strstr(gl_renderer, "X1400")
1401 || strstr(gl_renderer, "X1450")
1402 || strstr(gl_renderer, "X1550"))
1403 {
1404 *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */
1405 return CARD_ATI_RADEON_X700;
1406 }
1407
1408 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1409 if (strstr(gl_renderer, "Radeon Xpress"))
1410 {
1411 *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */
1412 return CARD_ATI_RADEON_XPRESS_200M;
1413 }
1414
1415 /* Radeon R3xx */
1416 *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */
1417 return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
1418 }
1419
1420 if (WINE_D3D8_CAPABLE(gl_info))
1421 {
1422 *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */
1423 return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
1424 }
1425
1426 if (WINE_D3D7_CAPABLE(gl_info))
1427 {
1428 *vidmem = 32; /* There are models with up to 64MB */
1429 return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
1430 }
1431
1432 *vidmem = 16; /* There are 16-32MB models */
1433 return CARD_ATI_RAGE_128PRO;
1434
1435 case VENDOR_INTEL:
1436 if (strstr(gl_renderer, "X3100"))
1437 {
1438 /* MacOS calls the card GMA X3100, Google findings also suggest the name GM965 */
1439 *vidmem = 128;
1440 return CARD_INTEL_X3100;
1441 }
1442
1443 if (strstr(gl_renderer, "GMA 950") || strstr(gl_renderer, "945GM"))
1444 {
1445 /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
1446 *vidmem = 64;
1447 return CARD_INTEL_I945GM;
1448 }
1449
1450 if (strstr(gl_renderer, "915GM")) return CARD_INTEL_I915GM;
1451 if (strstr(gl_renderer, "915G")) return CARD_INTEL_I915G;
1452 if (strstr(gl_renderer, "865G")) return CARD_INTEL_I865G;
1453 if (strstr(gl_renderer, "855G")) return CARD_INTEL_I855G;
1454 if (strstr(gl_renderer, "830G")) return CARD_INTEL_I830G;
1455 return CARD_INTEL_I915G;
1456
1457 case VENDOR_MESA:
1458 case VENDOR_WINE:
1459 default:
1460 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
1461 * for Nvidia was because the hardware and drivers they make are of good quality. This makes
1462 * them a good generic choice. */
1463 *vendor = VENDOR_NVIDIA;
1464 if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600;
1465 if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3;
1466 if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE;
1467 if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT;
1468 return CARD_NVIDIA_RIVA_128;
1469 }
1470}
1471
1472/* Context activation is done by the caller. */
1473static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_gl_info *gl_info)
1474{
1475 const char *GL_Extensions = NULL;
1476 const char *WGL_Extensions = NULL;
1477 const char *gl_string = NULL;
1478 GLint gl_max;
1479 GLfloat gl_floatv[2];
1480 unsigned i;
1481 HDC hdc;
1482 unsigned int vidmem=0;
1483 char *gl_renderer;
1484 DWORD gl_version;
1485 size_t len;
1486
1487 TRACE_(d3d_caps)("(%p)\n", gl_info);
1488
1489 ENTER_GL();
1490
1491 gl_string = (const char *)glGetString(GL_RENDERER);
1492 TRACE_(d3d_caps)("GL_RENDERER: %s.\n", debugstr_a(gl_string));
1493 if (!gl_string)
1494 {
1495 LEAVE_GL();
1496 ERR_(d3d_caps)("Received a NULL GL_RENDERER.\n");
1497 return FALSE;
1498 }
1499
1500 len = strlen(gl_string) + 1;
1501 gl_renderer = HeapAlloc(GetProcessHeap(), 0, len);
1502 if (!gl_renderer)
1503 {
1504 LEAVE_GL();
1505 ERR_(d3d_caps)("Failed to allocate gl_renderer memory.\n");
1506 return FALSE;
1507 }
1508 memcpy(gl_renderer, gl_string, len);
1509
1510 gl_string = (const char *)glGetString(GL_VENDOR);
1511 TRACE_(d3d_caps)("GL_VENDOR: %s.\n", debugstr_a(gl_string));
1512 if (!gl_string)
1513 {
1514 LEAVE_GL();
1515 ERR_(d3d_caps)("Received a NULL GL_VENDOR.\n");
1516 HeapFree(GetProcessHeap(), 0, gl_renderer);
1517 return FALSE;
1518 }
1519 gl_info->gl_vendor = wined3d_guess_vendor(gl_string, gl_renderer);
1520 TRACE_(d3d_caps)("found GL_VENDOR (%s)->(0x%04x)\n", debugstr_a(gl_string), gl_info->gl_vendor);
1521
1522 /* Parse the GL_VERSION field into major and minor information */
1523 gl_string = (const char *)glGetString(GL_VERSION);
1524 TRACE_(d3d_caps)("GL_VERSION: %s.\n", debugstr_a(gl_string));
1525 if (!gl_string)
1526 {
1527 LEAVE_GL();
1528 ERR_(d3d_caps)("Received a NULL GL_VERSION.\n");
1529 HeapFree(GetProcessHeap(), 0, gl_renderer);
1530 return FALSE;
1531 }
1532 gl_version = wined3d_parse_gl_version(gl_string);
1533
1534 /*
1535 * Initialize openGL extension related variables
1536 * with Default values
1537 */
1538 memset(gl_info->supported, 0, sizeof(gl_info->supported));
1539 gl_info->max_buffers = 1;
1540 gl_info->max_textures = 1;
1541 gl_info->max_texture_stages = 1;
1542 gl_info->max_fragment_samplers = 1;
1543 gl_info->max_vertex_samplers = 0;
1544 gl_info->max_combined_samplers = gl_info->max_fragment_samplers + gl_info->max_vertex_samplers;
1545 gl_info->max_sampler_stages = 1;
1546 gl_info->ps_arb_max_temps = 0;
1547 gl_info->ps_arb_max_instructions = 0;
1548 gl_info->vs_arb_max_temps = 0;
1549 gl_info->vs_arb_max_instructions = 0;
1550 gl_info->vs_glsl_constantsF = 0;
1551 gl_info->ps_glsl_constantsF = 0;
1552 gl_info->vs_arb_constantsF = 0;
1553 gl_info->ps_arb_constantsF = 0;
1554 gl_info->ps_arb_max_local_constants = 0;
1555
1556 /* Retrieve opengl defaults */
1557 glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max);
1558 gl_info->max_clipplanes = min(WINED3DMAXUSERCLIPPLANES, gl_max);
1559 TRACE_(d3d_caps)("ClipPlanes support - num Planes=%d\n", gl_max);
1560
1561 glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
1562 gl_info->max_lights = gl_max;
1563 TRACE_(d3d_caps)("Lights support - max lights=%d\n", gl_max);
1564
1565 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max);
1566 gl_info->max_texture_size = gl_max;
1567 TRACE_(d3d_caps)("Maximum texture size support - max texture size=%d\n", gl_max);
1568
1569 glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, gl_floatv);
1570 gl_info->max_pointsizemin = gl_floatv[0];
1571 gl_info->max_pointsize = gl_floatv[1];
1572 TRACE_(d3d_caps)("Maximum point size support - max point size=%f\n", gl_floatv[1]);
1573
1574 /* Parse the gl supported features, in theory enabling parts of our code appropriately. */
1575 GL_Extensions = (const char *)glGetString(GL_EXTENSIONS);
1576 if (!GL_Extensions)
1577 {
1578 LEAVE_GL();
1579 ERR_(d3d_caps)("Received a NULL GL_EXTENSIONS.\n");
1580 HeapFree(GetProcessHeap(), 0, gl_renderer);
1581 return FALSE;
1582 }
1583
1584 LEAVE_GL();
1585
1586 TRACE_(d3d_caps)("GL_Extensions reported:\n");
1587
1588 gl_info->supported[WINED3D_GL_EXT_NONE] = TRUE;
1589
1590 while (*GL_Extensions)
1591 {
1592 const char *start;
1593 char current_ext[256];
1594
1595 while (isspace(*GL_Extensions)) ++GL_Extensions;
1596 start = GL_Extensions;
1597 while (!isspace(*GL_Extensions) && *GL_Extensions) ++GL_Extensions;
1598
1599 len = GL_Extensions - start;
1600 if (!len || len >= sizeof(current_ext)) continue;
1601
1602 memcpy(current_ext, start, len);
1603 current_ext[len] = '\0';
1604 TRACE_(d3d_caps)("- %s\n", debugstr_a(current_ext));
1605
1606 for (i = 0; i < (sizeof(EXTENSION_MAP) / sizeof(*EXTENSION_MAP)); ++i)
1607 {
1608 if (!strcmp(current_ext, EXTENSION_MAP[i].extension_string))
1609 {
1610 TRACE_(d3d_caps)(" FOUND: %s support.\n", EXTENSION_MAP[i].extension_string);
1611 gl_info->supported[EXTENSION_MAP[i].extension] = TRUE;
1612 break;
1613 }
1614 }
1615 }
1616
1617 /* Now work out what GL support this card really has */
1618#define USE_GL_FUNC(type, pfn, ext, replace) \
1619{ \
1620 DWORD ver = ver_for_ext(ext); \
1621 if (gl_info->supported[ext]) gl_info->pfn = (type)pwglGetProcAddress(#pfn); \
1622 else if (ver && ver <= gl_version) gl_info->pfn = (type)pwglGetProcAddress(#replace); \
1623 else gl_info->pfn = NULL; \
1624}
1625 GL_EXT_FUNCS_GEN;
1626#undef USE_GL_FUNC
1627
1628#define USE_GL_FUNC(type, pfn, ext, replace) gl_info->pfn = (type)pwglGetProcAddress(#pfn);
1629 WGL_EXT_FUNCS_GEN;
1630#undef USE_GL_FUNC
1631
1632 ENTER_GL();
1633
1634 /* Now mark all the extensions supported which are included in the opengl core version. Do this *after*
1635 * loading the functions, otherwise the code above will load the extension entry points instead of the
1636 * core functions, which may not work. */
1637 for (i = 0; i < (sizeof(EXTENSION_MAP) / sizeof(*EXTENSION_MAP)); ++i)
1638 {
1639 if (!gl_info->supported[EXTENSION_MAP[i].extension]
1640 && EXTENSION_MAP[i].version <= gl_version && EXTENSION_MAP[i].version)
1641 {
1642 TRACE_(d3d_caps)(" GL CORE: %s support.\n", EXTENSION_MAP[i].extension_string);
1643 gl_info->supported[EXTENSION_MAP[i].extension] = TRUE;
1644 }
1645 }
1646
1647 if (gl_info->supported[APPLE_FENCE])
1648 {
1649 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
1650 * The apple extension interacts with some other apple exts. Disable the NV
1651 * extension if the apple one is support to prevent confusion in other parts
1652 * of the code. */
1653 gl_info->supported[NV_FENCE] = FALSE;
1654 }
1655 if (gl_info->supported[APPLE_FLOAT_PIXELS])
1656 {
1657 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
1658 *
1659 * The enums are the same:
1660 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881A
1661 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881B
1662 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
1663 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
1664 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140B
1665 */
1666 if (!gl_info->supported[ARB_TEXTURE_FLOAT])
1667 {
1668 TRACE_(d3d_caps)(" IMPLIED: GL_ARB_texture_float support(from GL_APPLE_float_pixels.\n");
1669 gl_info->supported[ARB_TEXTURE_FLOAT] = TRUE;
1670 }
1671 if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
1672 {
1673 TRACE_(d3d_caps)(" IMPLIED: GL_ARB_half_float_pixel support(from GL_APPLE_float_pixels.\n");
1674 gl_info->supported[ARB_HALF_FLOAT_PIXEL] = TRUE;
1675 }
1676 }
1677 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
1678 {
1679 TRACE_(d3d_caps)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
1680 gl_info->supported[NV_TEXGEN_REFLECTION] = TRUE;
1681 }
1682 if (!gl_info->supported[ARB_DEPTH_CLAMP] && gl_info->supported[NV_DEPTH_CLAMP])
1683 {
1684 TRACE_(d3d_caps)(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
1685 gl_info->supported[ARB_DEPTH_CLAMP] = TRUE;
1686 }
1687 if (gl_info->supported[NV_TEXTURE_SHADER2])
1688 {
1689 if (gl_info->supported[NV_REGISTER_COMBINERS])
1690 {
1691 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
1692 * are supported. The nv extensions provide the same functionality as the
1693 * ATI one, and a bit more(signed pixelformats). */
1694 gl_info->supported[ATI_FRAGMENT_SHADER] = FALSE;
1695 }
1696 }
1697 if (gl_info->supported[ARB_DRAW_BUFFERS])
1698 {
1699 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max);
1700 gl_info->max_buffers = gl_max;
1701 TRACE_(d3d_caps)("Max draw buffers: %u.\n", gl_max);
1702 }
1703 if (gl_info->supported[ARB_MULTITEXTURE])
1704 {
1705 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
1706 gl_info->max_textures = min(MAX_TEXTURES, gl_max);
1707 TRACE_(d3d_caps)("Max textures: %d.\n", gl_info->max_textures);
1708
1709 if (gl_info->supported[NV_REGISTER_COMBINERS])
1710 {
1711 GLint tmp;
1712 glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &tmp);
1713 gl_info->max_texture_stages = min(MAX_TEXTURES, tmp);
1714 }
1715 else
1716 {
1717 gl_info->max_texture_stages = min(MAX_TEXTURES, gl_max);
1718 }
1719 TRACE_(d3d_caps)("Max texture stages: %d.\n", gl_info->max_texture_stages);
1720
1721 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
1722 {
1723 GLint tmp;
1724 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &tmp);
1725 gl_info->max_fragment_samplers = min(MAX_FRAGMENT_SAMPLERS, tmp);
1726 }
1727 else
1728 {
1729 gl_info->max_fragment_samplers = max(gl_info->max_fragment_samplers, gl_max);
1730 }
1731 TRACE_(d3d_caps)("Max fragment samplers: %d.\n", gl_info->max_fragment_samplers);
1732
1733 if (gl_info->supported[ARB_VERTEX_SHADER])
1734 {
1735 GLint tmp;
1736 glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &tmp);
1737 gl_info->max_vertex_samplers = tmp;
1738 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &tmp);
1739 gl_info->max_combined_samplers = tmp;
1740
1741 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
1742 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
1743 * an issue because then the sampler setup only depends on the two shaders. If a pixel
1744 * shader is used with fixed function vertex processing we're fine too because fixed function
1745 * vertex processing doesn't use any samplers. If fixed function fragment processing is
1746 * used we have to make sure that all vertex sampler setups are valid together with all
1747 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
1748 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
1749 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
1750 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
1751 * a fixed function pipeline anymore.
1752 *
1753 * So this is just a check to check that our assumption holds true. If not, write a warning
1754 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
1755 if (gl_info->max_vertex_samplers && gl_info->max_combined_samplers < 12
1756 && MAX_TEXTURES + gl_info->max_vertex_samplers > gl_info->max_combined_samplers)
1757 {
1758 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
1759 gl_info->max_vertex_samplers, gl_info->max_combined_samplers);
1760 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
1761 if (gl_info->max_combined_samplers > MAX_TEXTURES)
1762 gl_info->max_vertex_samplers = gl_info->max_combined_samplers - MAX_TEXTURES;
1763 else
1764 gl_info->max_vertex_samplers = 0;
1765 }
1766 }
1767 else
1768 {
1769 gl_info->max_combined_samplers = gl_info->max_fragment_samplers;
1770 }
1771 TRACE_(d3d_caps)("Max vertex samplers: %u.\n", gl_info->max_vertex_samplers);
1772 TRACE_(d3d_caps)("Max combined samplers: %u.\n", gl_info->max_combined_samplers);
1773 }
1774 if (gl_info->supported[ARB_VERTEX_BLEND])
1775 {
1776 glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
1777 gl_info->max_blends = gl_max;
1778 TRACE_(d3d_caps)("Max blends: %u.\n", gl_info->max_blends);
1779 }
1780 if (gl_info->supported[EXT_TEXTURE3D])
1781 {
1782 glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &gl_max);
1783 gl_info->max_texture3d_size = gl_max;
1784 TRACE_(d3d_caps)("Max texture3D size: %d.\n", gl_info->max_texture3d_size);
1785 }
1786 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
1787 {
1788 glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max);
1789 gl_info->max_anisotropy = gl_max;
1790 TRACE_(d3d_caps)("Max anisotropy: %d.\n", gl_info->max_anisotropy);
1791 }
1792 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
1793 {
1794 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
1795 gl_info->ps_arb_constantsF = gl_max;
1796 TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info->ps_arb_constantsF);
1797 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
1798 gl_info->ps_arb_max_temps = gl_max;
1799 TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info->ps_arb_max_temps);
1800 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
1801 gl_info->ps_arb_max_instructions = gl_max;
1802 TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info->ps_arb_max_instructions);
1803 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &gl_max));
1804 gl_info->ps_arb_max_local_constants = gl_max;
1805 TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info->ps_arb_max_instructions);
1806 }
1807 if (gl_info->supported[ARB_VERTEX_PROGRAM])
1808 {
1809 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
1810 gl_info->vs_arb_constantsF = gl_max;
1811 TRACE_(d3d_caps)("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info->vs_arb_constantsF);
1812 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
1813 gl_info->vs_arb_max_temps = gl_max;
1814 TRACE_(d3d_caps)("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info->vs_arb_max_temps);
1815 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
1816 gl_info->vs_arb_max_instructions = gl_max;
1817 TRACE_(d3d_caps)("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info->vs_arb_max_instructions);
1818
1819 if (test_arb_vs_offset_limit(gl_info)) gl_info->quirks |= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT;
1820 }
1821 if (gl_info->supported[ARB_VERTEX_SHADER])
1822 {
1823 glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &gl_max);
1824 gl_info->vs_glsl_constantsF = gl_max / 4;
1825 TRACE_(d3d_caps)("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info->vs_glsl_constantsF);
1826 }
1827 if (gl_info->supported[ARB_FRAGMENT_SHADER])
1828 {
1829 glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &gl_max);
1830 gl_info->ps_glsl_constantsF = gl_max / 4;
1831 TRACE_(d3d_caps)("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info->ps_glsl_constantsF);
1832 glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
1833 gl_info->max_glsl_varyings = gl_max;
1834 TRACE_(d3d_caps)("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
1835 }
1836 if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
1837 {
1838 glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->max_shininess);
1839 }
1840 else
1841 {
1842 gl_info->max_shininess = 128.0f;
1843 }
1844 if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
1845 {
1846 /* If we have full NP2 texture support, disable
1847 * GL_ARB_texture_rectangle because we will never use it.
1848 * This saves a few redundant glDisable calls. */
1849 gl_info->supported[ARB_TEXTURE_RECTANGLE] = FALSE;
1850 }
1851 if (gl_info->supported[ATI_FRAGMENT_SHADER])
1852 {
1853 /* Disable NV_register_combiners and fragment shader if this is supported.
1854 * generally the NV extensions are preferred over the ATI ones, and this
1855 * extension is disabled if register_combiners and texture_shader2 are both
1856 * supported. So we reach this place only if we have incomplete NV dxlevel 8
1857 * fragment processing support. */
1858 gl_info->supported[NV_REGISTER_COMBINERS] = FALSE;
1859 gl_info->supported[NV_REGISTER_COMBINERS2] = FALSE;
1860 gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
1861 gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
1862 gl_info->supported[NV_TEXTURE_SHADER3] = FALSE;
1863 }
1864 if (gl_info->supported[NV_HALF_FLOAT])
1865 {
1866 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
1867 gl_info->supported[ARB_HALF_FLOAT_VERTEX] = TRUE;
1868 }
1869 if (gl_info->supported[ARB_POINT_SPRITE])
1870 {
1871 gl_info->max_point_sprite_units = gl_info->max_textures;
1872 }
1873 else
1874 {
1875 gl_info->max_point_sprite_units = 0;
1876 }
1877 checkGLcall("extension detection");
1878
1879 LEAVE_GL();
1880
1881 /* In some cases the number of texture stages can be larger than the number
1882 * of samplers. The GF4 for example can use only 2 samplers (no fragment
1883 * shaders), but 8 texture stages (register combiners). */
1884 gl_info->max_sampler_stages = max(gl_info->max_fragment_samplers, gl_info->max_texture_stages);
1885
1886 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
1887 {
1888 gl_info->fbo_ops.glIsRenderbuffer = gl_info->glIsRenderbuffer;
1889 gl_info->fbo_ops.glBindRenderbuffer = gl_info->glBindRenderbuffer;
1890 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->glDeleteRenderbuffers;
1891 gl_info->fbo_ops.glGenRenderbuffers = gl_info->glGenRenderbuffers;
1892 gl_info->fbo_ops.glRenderbufferStorage = gl_info->glRenderbufferStorage;
1893 gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->glRenderbufferStorageMultisample;
1894 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->glGetRenderbufferParameteriv;
1895 gl_info->fbo_ops.glIsFramebuffer = gl_info->glIsFramebuffer;
1896 gl_info->fbo_ops.glBindFramebuffer = gl_info->glBindFramebuffer;
1897 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->glDeleteFramebuffers;
1898 gl_info->fbo_ops.glGenFramebuffers = gl_info->glGenFramebuffers;
1899 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->glCheckFramebufferStatus;
1900 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->glFramebufferTexture1D;
1901 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->glFramebufferTexture2D;
1902 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->glFramebufferTexture3D;
1903 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->glFramebufferRenderbuffer;
1904 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv = gl_info->glGetFramebufferAttachmentParameteriv;
1905 gl_info->fbo_ops.glBlitFramebuffer = gl_info->glBlitFramebuffer;
1906 gl_info->fbo_ops.glGenerateMipmap = gl_info->glGenerateMipmap;
1907 }
1908 else
1909 {
1910 if (gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
1911 {
1912 gl_info->fbo_ops.glIsRenderbuffer = gl_info->glIsRenderbufferEXT;
1913 gl_info->fbo_ops.glBindRenderbuffer = gl_info->glBindRenderbufferEXT;
1914 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->glDeleteRenderbuffersEXT;
1915 gl_info->fbo_ops.glGenRenderbuffers = gl_info->glGenRenderbuffersEXT;
1916 gl_info->fbo_ops.glRenderbufferStorage = gl_info->glRenderbufferStorageEXT;
1917 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->glGetRenderbufferParameterivEXT;
1918 gl_info->fbo_ops.glIsFramebuffer = gl_info->glIsFramebufferEXT;
1919 gl_info->fbo_ops.glBindFramebuffer = gl_info->glBindFramebufferEXT;
1920 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->glDeleteFramebuffersEXT;
1921 gl_info->fbo_ops.glGenFramebuffers = gl_info->glGenFramebuffersEXT;
1922 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->glCheckFramebufferStatusEXT;
1923 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->glFramebufferTexture1DEXT;
1924 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->glFramebufferTexture2DEXT;
1925 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->glFramebufferTexture3DEXT;
1926 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->glFramebufferRenderbufferEXT;
1927 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv = gl_info->glGetFramebufferAttachmentParameterivEXT;
1928 gl_info->fbo_ops.glGenerateMipmap = gl_info->glGenerateMipmapEXT;
1929 }
1930 else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
1931 {
1932 WARN_(d3d_caps)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
1933 wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
1934 }
1935 if (gl_info->supported[EXT_FRAMEBUFFER_BLIT])
1936 {
1937 gl_info->fbo_ops.glBlitFramebuffer = gl_info->glBlitFramebufferEXT;
1938 }
1939 if (gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
1940 {
1941 gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->glRenderbufferStorageMultisampleEXT;
1942 }
1943 }
1944
1945 /* MRTs are currently only supported when FBOs are used. */
1946 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) {
1947 gl_info->max_buffers = 1;
1948 }
1949
1950 gl_info->gl_card = wined3d_guess_card(gl_info, gl_renderer, &gl_info->gl_vendor, &vidmem);
1951 TRACE_(d3d_caps)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", gl_info->gl_vendor, gl_info->gl_card);
1952
1953 /* If we have an estimate use it, else default to 64MB; */
1954 if(vidmem)
1955 gl_info->vidmem = vidmem*1024*1024; /* convert from MBs to bytes */
1956 else
1957 gl_info->vidmem = WINE_DEFAULT_VIDMEM;
1958
1959 /* Load all the lookup tables */
1960 for (i = 0; i < MAX_LOOKUPS; i++) {
1961 stateLookup[i] = HeapAlloc(GetProcessHeap(), 0, sizeof(*stateLookup[i]) * (1 + maxLookup[i] - minLookup[i]) );
1962 }
1963
1964 stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_WRAP - minLookup[WINELOOKUP_WARPPARAM]] = GL_REPEAT;
1965 stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_CLAMP - minLookup[WINELOOKUP_WARPPARAM]] = GL_CLAMP_TO_EDGE;
1966 stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_BORDER - minLookup[WINELOOKUP_WARPPARAM]] =
1967 gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
1968 stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_BORDER - minLookup[WINELOOKUP_WARPPARAM]] =
1969 gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
1970 stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_MIRROR - minLookup[WINELOOKUP_WARPPARAM]] =
1971 gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
1972 stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_MIRRORONCE - minLookup[WINELOOKUP_WARPPARAM]] =
1973 gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] ? GL_MIRROR_CLAMP_TO_EDGE_ATI : GL_REPEAT;
1974
1975 /* Make sure there's an active HDC else the WGL extensions will fail */
1976 hdc = pwglGetCurrentDC();
1977 if (hdc) {
1978 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox */
1979 if(GL_EXTCALL(wglGetExtensionsStringARB))
1980 WGL_Extensions = GL_EXTCALL(wglGetExtensionsStringARB(hdc));
1981
1982 if (NULL == WGL_Extensions) {
1983 ERR(" WGL_Extensions returns NULL\n");
1984 } else {
1985 TRACE_(d3d_caps)("WGL_Extensions reported:\n");
1986 while (*WGL_Extensions != 0x00) {
1987 const char *Start;
1988 char ThisExtn[256];
1989
1990 while (isspace(*WGL_Extensions)) WGL_Extensions++;
1991 Start = WGL_Extensions;
1992 while (!isspace(*WGL_Extensions) && *WGL_Extensions != 0x00) {
1993 WGL_Extensions++;
1994 }
1995
1996 len = WGL_Extensions - Start;
1997 if (len == 0 || len >= sizeof(ThisExtn))
1998 continue;
1999
2000 memcpy(ThisExtn, Start, len);
2001 ThisExtn[len] = '\0';
2002 TRACE_(d3d_caps)("- %s\n", debugstr_a(ThisExtn));
2003
2004 if (!strcmp(ThisExtn, "WGL_ARB_pbuffer")) {
2005 gl_info->supported[WGL_ARB_PBUFFER] = TRUE;
2006 TRACE_(d3d_caps)("FOUND: WGL_ARB_pbuffer support\n");
2007 }
2008 if (!strcmp(ThisExtn, "WGL_ARB_pixel_format")) {
2009 gl_info->supported[WGL_ARB_PIXEL_FORMAT] = TRUE;
2010 TRACE_(d3d_caps)("FOUND: WGL_ARB_pixel_format support\n");
2011 }
2012 if (!strcmp(ThisExtn, "WGL_WINE_pixel_format_passthrough")) {
2013 gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH] = TRUE;
2014 TRACE_(d3d_caps)("FOUND: WGL_WINE_pixel_format_passthrough support\n");
2015 }
2016 }
2017 }
2018 }
2019
2020 fixup_extensions(gl_info, gl_renderer);
2021 add_gl_compat_wrappers(gl_info);
2022
2023 HeapFree(GetProcessHeap(), 0, gl_renderer);
2024 return TRUE;
2025}
2026
2027/**********************************************************
2028 * IWineD3D implementation follows
2029 **********************************************************/
2030
2031static UINT WINAPI IWineD3DImpl_GetAdapterCount (IWineD3D *iface) {
2032 IWineD3DImpl *This = (IWineD3DImpl *)iface;
2033
2034 TRACE_(d3d_caps)("(%p): Reporting %u adapters\n", This, This->adapter_count);
2035
2036 return This->adapter_count;
2037}
2038
2039static HRESULT WINAPI IWineD3DImpl_RegisterSoftwareDevice(IWineD3D *iface, void* pInitializeFunction) {
2040 IWineD3DImpl *This = (IWineD3DImpl *)iface;
2041 FIXME("(%p)->(%p): stub\n", This, pInitializeFunction);
2042 return WINED3D_OK;
2043}
2044
2045static HMONITOR WINAPI IWineD3DImpl_GetAdapterMonitor(IWineD3D *iface, UINT Adapter) {
2046 IWineD3DImpl *This = (IWineD3DImpl *)iface;
2047
2048 TRACE_(d3d_caps)("(%p)->(%d)\n", This, Adapter);
2049
2050 if (Adapter >= IWineD3DImpl_GetAdapterCount(iface)) {
2051 return NULL;
2052 }
2053
2054 return MonitorFromPoint(This->adapters[Adapter].monitorPoint, MONITOR_DEFAULTTOPRIMARY);
2055}
2056
2057/* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
2058 of the same bpp but different resolutions */
2059
2060/* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2061static UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Adapter, WINED3DFORMAT Format) {
2062 IWineD3DImpl *This = (IWineD3DImpl *)iface;
2063 TRACE_(d3d_caps)("(%p}->(Adapter: %d, Format: %s)\n", This, Adapter, debug_d3dformat(Format));
2064
2065 if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
2066 return 0;
2067 }
2068
2069 /* TODO: Store modes per adapter and read it from the adapter structure */
2070 if (Adapter == 0) { /* Display */
2071 unsigned int i = 0;
2072 unsigned int j = 0;
2073 DEVMODEW mode;
2074
2075 memset(&mode, 0, sizeof(mode));
2076 mode.dmSize = sizeof(mode);
2077
2078 while (EnumDisplaySettingsExW(NULL, j, &mode, 0))
2079 {
2080 ++j;
2081 switch (Format)
2082 {
2083 case WINED3DFMT_UNKNOWN:
2084 /* This is for D3D8, do not enumerate P8 here */
2085 if (mode.dmBitsPerPel == 32 || mode.dmBitsPerPel == 16) ++i;
2086 break;
2087
2088 case WINED3DFMT_B8G8R8X8_UNORM:
2089 if (mode.dmBitsPerPel == 32) ++i;
2090 break;
2091
2092 case WINED3DFMT_B5G6R5_UNORM:
2093 if (mode.dmBitsPerPel == 16) ++i;
2094 break;
2095
2096 case WINED3DFMT_P8_UINT:
2097 if (mode.dmBitsPerPel == 8) ++i;
2098 break;
2099
2100 default:
2101 /* Skip other modes as they do not match the requested format */
2102 break;
2103 }
2104 }
2105
2106 TRACE_(d3d_caps)("(%p}->(Adapter: %d) => %d (out of %d)\n", This, Adapter, i, j);
2107 return i;
2108 } else {
2109 FIXME_(d3d_caps)("Adapter not primary display\n");
2110 }
2111 return 0;
2112}
2113
2114/* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2115static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapter, WINED3DFORMAT Format, UINT Mode, WINED3DDISPLAYMODE* pMode) {
2116 IWineD3DImpl *This = (IWineD3DImpl *)iface;
2117 TRACE_(d3d_caps)("(%p}->(Adapter:%d, mode:%d, pMode:%p, format:%s)\n", This, Adapter, Mode, pMode, debug_d3dformat(Format));
2118
2119 /* Validate the parameters as much as possible */
2120 if (NULL == pMode ||
2121 Adapter >= IWineD3DImpl_GetAdapterCount(iface) ||
2122 Mode >= IWineD3DImpl_GetAdapterModeCount(iface, Adapter, Format)) {
2123 return WINED3DERR_INVALIDCALL;
2124 }
2125
2126 /* TODO: Store modes per adapter and read it from the adapter structure */
2127 if (Adapter == 0)
2128 {
2129 DEVMODEW DevModeW;
2130 int ModeIdx = 0;
2131 UINT i = 0;
2132 int j = 0;
2133
2134 ZeroMemory(&DevModeW, sizeof(DevModeW));
2135 DevModeW.dmSize = sizeof(DevModeW);
2136
2137 /* If we are filtering to a specific format (D3D9), then need to skip
2138 all unrelated modes, but if mode is irrelevant (D3D8), then we can
2139 just count through the ones with valid bit depths */
2140 while ((i<=Mode) && EnumDisplaySettingsExW(NULL, j++, &DevModeW, 0)) {
2141 switch (Format)
2142 {
2143 case WINED3DFMT_UNKNOWN:
2144 /* This is D3D8. Do not enumerate P8 here */
2145 if (DevModeW.dmBitsPerPel == 32 ||
2146 DevModeW.dmBitsPerPel == 16) i++;
2147 break;
2148 case WINED3DFMT_B8G8R8X8_UNORM:
2149 if (DevModeW.dmBitsPerPel == 32) i++;
2150 break;
2151 case WINED3DFMT_B5G6R5_UNORM:
2152 if (DevModeW.dmBitsPerPel == 16) i++;
2153 break;
2154 case WINED3DFMT_P8_UINT:
2155 if (DevModeW.dmBitsPerPel == 8) i++;
2156 break;
2157 default:
2158 /* Modes that don't match what we support can get an early-out */
2159 TRACE_(d3d_caps)("Searching for %s, returning D3DERR_INVALIDCALL\n", debug_d3dformat(Format));
2160 return WINED3DERR_INVALIDCALL;
2161 }
2162 }
2163
2164 if (i == 0) {
2165 TRACE_(d3d_caps)("No modes found for format (%x - %s)\n", Format, debug_d3dformat(Format));
2166 return WINED3DERR_INVALIDCALL;
2167 }
2168 ModeIdx = j - 1;
2169
2170 /* Now get the display mode via the calculated index */
2171 if (EnumDisplaySettingsExW(NULL, ModeIdx, &DevModeW, 0)) {
2172 pMode->Width = DevModeW.dmPelsWidth;
2173 pMode->Height = DevModeW.dmPelsHeight;
2174 pMode->RefreshRate = DEFAULT_REFRESH_RATE;
2175 if (DevModeW.dmFields & DM_DISPLAYFREQUENCY)
2176 pMode->RefreshRate = DevModeW.dmDisplayFrequency;
2177
2178 if (Format == WINED3DFMT_UNKNOWN) {
2179 pMode->Format = pixelformat_for_depth(DevModeW.dmBitsPerPel);
2180 } else {
2181 pMode->Format = Format;
2182 }
2183 } else {
2184 TRACE_(d3d_caps)("Requested mode out of range %d\n", Mode);
2185 return WINED3DERR_INVALIDCALL;
2186 }
2187
2188 TRACE_(d3d_caps)("W %d H %d rr %d fmt (%x - %s) bpp %u\n", pMode->Width, pMode->Height,
2189 pMode->RefreshRate, pMode->Format, debug_d3dformat(pMode->Format),
2190 DevModeW.dmBitsPerPel);
2191
2192 }
2193 else
2194 {
2195 FIXME_(d3d_caps)("Adapter not primary display\n");
2196 }
2197
2198 return WINED3D_OK;
2199}
2200
2201static HRESULT WINAPI IWineD3DImpl_GetAdapterDisplayMode(IWineD3D *iface, UINT Adapter, WINED3DDISPLAYMODE* pMode) {
2202 IWineD3DImpl *This = (IWineD3DImpl *)iface;
2203 TRACE_(d3d_caps)("(%p}->(Adapter: %d, pMode: %p)\n", This, Adapter, pMode);
2204
2205 if (NULL == pMode ||
2206 Adapter >= IWineD3D_GetAdapterCount(iface)) {
2207 return WINED3DERR_INVALIDCALL;
2208 }
2209
2210 if (Adapter == 0) { /* Display */
2211 int bpp = 0;
2212 DEVMODEW DevModeW;
2213
2214 ZeroMemory(&DevModeW, sizeof(DevModeW));
2215 DevModeW.dmSize = sizeof(DevModeW);
2216
2217 EnumDisplaySettingsExW(NULL, ENUM_CURRENT_SETTINGS, &DevModeW, 0);
2218 pMode->Width = DevModeW.dmPelsWidth;
2219 pMode->Height = DevModeW.dmPelsHeight;
2220 bpp = DevModeW.dmBitsPerPel;
2221 pMode->RefreshRate = DEFAULT_REFRESH_RATE;
2222 if (DevModeW.dmFields&DM_DISPLAYFREQUENCY)
2223 {
2224 pMode->RefreshRate = DevModeW.dmDisplayFrequency;
2225 }
2226
2227 pMode->Format = pixelformat_for_depth(bpp);
2228 } else {
2229 FIXME_(d3d_caps)("Adapter not primary display\n");
2230 }
2231
2232 TRACE_(d3d_caps)("returning w:%d, h:%d, ref:%d, fmt:%s\n", pMode->Width,
2233 pMode->Height, pMode->RefreshRate, debug_d3dformat(pMode->Format));
2234 return WINED3D_OK;
2235}
2236
2237/* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
2238 and fields being inserted in the middle, a new structure is used in place */
2239static HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Adapter, DWORD Flags,
2240 WINED3DADAPTER_IDENTIFIER* pIdentifier) {
2241 IWineD3DImpl *This = (IWineD3DImpl *)iface;
2242 size_t len;
2243
2244 TRACE_(d3d_caps)("(%p}->(Adapter: %d, Flags: %x, pId=%p)\n", This, Adapter, Flags, pIdentifier);
2245
2246 if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
2247 return WINED3DERR_INVALIDCALL;
2248 }
2249
2250 /* Return the information requested */
2251 TRACE_(d3d_caps)("device/Vendor Name and Version detection using FillGLCaps\n");
2252
2253 if (pIdentifier->driver_size)
2254 {
2255 len = min(strlen(This->adapters[Adapter].driver), pIdentifier->driver_size - 1);
2256 memcpy(pIdentifier->driver, This->adapters[Adapter].driver, len);
2257 pIdentifier->driver[len] = '\0';
2258 }
2259
2260 if (pIdentifier->description_size)
2261 {
2262 const char *description;
2263
2264 if (This->adapters[Adapter].gl_info.driver_description)
2265 description = This->adapters[Adapter].gl_info.driver_description;
2266 else
2267 description = This->adapters[Adapter].description;
2268
2269 len = min(strlen(description), pIdentifier->description_size - 1);
2270 memcpy(pIdentifier->description, description, len);
2271 pIdentifier->description[len] = '\0';
2272 }
2273
2274 /* Note that d3d8 doesn't supply a device name. */
2275 if (pIdentifier->device_name_size)
2276 {
2277 static const char *device_name = "\\\\.\\DISPLAY1"; /* FIXME: May depend on desktop? */
2278
2279 len = strlen(device_name);
2280 if (len >= pIdentifier->device_name_size)
2281 {
2282 ERR("Device name size too small.\n");
2283 return WINED3DERR_INVALIDCALL;
2284 }
2285
2286 memcpy(pIdentifier->device_name, device_name, len);
2287 pIdentifier->device_name[len] = '\0';
2288 }
2289
2290 pIdentifier->driver_version.u.HighPart = This->adapters[Adapter].gl_info.driver_version_hipart;
2291 pIdentifier->driver_version.u.LowPart = This->adapters[Adapter].gl_info.driver_version;
2292 pIdentifier->vendor_id = This->adapters[Adapter].gl_info.gl_vendor;
2293 pIdentifier->device_id = This->adapters[Adapter].gl_info.gl_card;
2294 pIdentifier->subsystem_id = 0;
2295 pIdentifier->revision = 0;
2296 memcpy(&pIdentifier->device_identifier, &IID_D3DDEVICE_D3DUID, sizeof(pIdentifier->device_identifier));
2297
2298 if(wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
2299 {
2300 TRACE_(d3d_caps)("Overriding pci device id with: %x\n", wined3d_settings.pci_device_id);
2301 pIdentifier->device_id = wined3d_settings.pci_device_id;
2302 }
2303
2304 if(wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
2305 {
2306 TRACE_(d3d_caps)("Overriding pci vendor id with: %x\n", wined3d_settings.pci_vendor_id);
2307 pIdentifier->vendor_id = wined3d_settings.pci_vendor_id;
2308 }
2309
2310 pIdentifier->whql_level = (Flags & WINED3DENUM_NO_WHQL_LEVEL) ? 0 : 1;
2311
2312 return WINED3D_OK;
2313}
2314
2315static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(const struct wined3d_gl_info *gl_info,
2316 const WineD3D_PixelFormat *cfg, const struct GlPixelFormatDesc *format_desc)
2317{
2318 short redSize, greenSize, blueSize, alphaSize, colorBits;
2319
2320 if(!cfg)
2321 return FALSE;
2322
2323 if(cfg->iPixelType == WGL_TYPE_RGBA_ARB) { /* Integer RGBA formats */
2324 if (!getColorBits(format_desc, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits))
2325 {
2326 ERR("Unable to check compatibility for Format=%s\n", debug_d3dformat(format_desc->format));
2327 return FALSE;
2328 }
2329
2330 if(cfg->redSize < redSize)
2331 return FALSE;
2332
2333 if(cfg->greenSize < greenSize)
2334 return FALSE;
2335
2336 if(cfg->blueSize < blueSize)
2337 return FALSE;
2338
2339 if(cfg->alphaSize < alphaSize)
2340 return FALSE;
2341
2342 return TRUE;
2343 } else if(cfg->iPixelType == WGL_TYPE_RGBA_FLOAT_ARB) { /* Float RGBA formats; TODO: WGL_NV_float_buffer */
2344 if (format_desc->format == WINED3DFMT_R16_FLOAT)
2345 return (cfg->redSize == 16 && cfg->greenSize == 0 && cfg->blueSize == 0 && cfg->alphaSize == 0);
2346 if (format_desc->format == WINED3DFMT_R16G16_FLOAT)
2347 return (cfg->redSize == 16 && cfg->greenSize == 16 && cfg->blueSize == 0 && cfg->alphaSize == 0);
2348 if (format_desc->format == WINED3DFMT_R16G16B16A16_FLOAT)
2349 return (cfg->redSize == 16 && cfg->greenSize == 16 && cfg->blueSize == 16 && cfg->alphaSize == 16);
2350 if (format_desc->format == WINED3DFMT_R32_FLOAT)
2351 return (cfg->redSize == 32 && cfg->greenSize == 0 && cfg->blueSize == 0 && cfg->alphaSize == 0);
2352 if (format_desc->format == WINED3DFMT_R32G32_FLOAT)
2353 return (cfg->redSize == 32 && cfg->greenSize == 32 && cfg->blueSize == 0 && cfg->alphaSize == 0);
2354 if (format_desc->format == WINED3DFMT_R32G32B32A32_FLOAT)
2355 return (cfg->redSize == 32 && cfg->greenSize == 32 && cfg->blueSize == 32 && cfg->alphaSize == 32);
2356 } else {
2357 /* Probably a color index mode */
2358 return FALSE;
2359 }
2360
2361 return FALSE;
2362}
2363
2364static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(const struct wined3d_gl_info *gl_info,
2365 const WineD3D_PixelFormat *cfg, const struct GlPixelFormatDesc *format_desc)
2366{
2367 short depthSize, stencilSize;
2368 BOOL lockable = FALSE;
2369
2370 if(!cfg)
2371 return FALSE;
2372
2373 if (!getDepthStencilBits(format_desc, &depthSize, &stencilSize))
2374 {
2375 ERR("Unable to check compatibility for Format=%s\n", debug_d3dformat(format_desc->format));
2376 return FALSE;
2377 }
2378
2379 if ((format_desc->format == WINED3DFMT_D16_LOCKABLE) || (format_desc->format == WINED3DFMT_D32_FLOAT))
2380 lockable = TRUE;
2381
2382 /* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports.
2383 * We can safely report 'compatible' formats (e.g. D24 can be used for D16) as long as we aren't dealing with
2384 * a lockable format. This also helps D3D <= 7 as they expect D16 which isn't offered without this on Geforce8 cards. */
2385 if(!(cfg->depthSize == depthSize || (!lockable && cfg->depthSize > depthSize)))
2386 return FALSE;
2387
2388 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
2389 * allow more stencil bits than requested. */
2390 if(cfg->stencilSize < stencilSize)
2391 return FALSE;
2392
2393 return TRUE;
2394}
2395
2396static HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
2397 WINED3DFORMAT AdapterFormat,
2398 WINED3DFORMAT RenderTargetFormat,
2399 WINED3DFORMAT DepthStencilFormat) {
2400 IWineD3DImpl *This = (IWineD3DImpl *)iface;
2401 int nCfgs;
2402 const WineD3D_PixelFormat *cfgs;
2403 const struct WineD3DAdapter *adapter;
2404 const struct GlPixelFormatDesc *rt_format_desc;
2405 const struct GlPixelFormatDesc *ds_format_desc;
2406 int it;
2407
2408 WARN_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n",
2409 This, Adapter,
2410 DeviceType, debug_d3ddevicetype(DeviceType),
2411 AdapterFormat, debug_d3dformat(AdapterFormat),
2412 RenderTargetFormat, debug_d3dformat(RenderTargetFormat),
2413 DepthStencilFormat, debug_d3dformat(DepthStencilFormat));
2414
2415 if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
2416 TRACE("(%p) Failed: Atapter (%u) higher than supported adapters (%u) returning WINED3DERR_INVALIDCALL\n", This, Adapter, IWineD3D_GetAdapterCount(iface));
2417 return WINED3DERR_INVALIDCALL;
2418 }
2419
2420 adapter = &This->adapters[Adapter];
2421 rt_format_desc = getFormatDescEntry(RenderTargetFormat, &adapter->gl_info);
2422 ds_format_desc = getFormatDescEntry(DepthStencilFormat, &adapter->gl_info);
2423 cfgs = adapter->cfgs;
2424 nCfgs = adapter->nCfgs;
2425 for (it = 0; it < nCfgs; ++it) {
2426 if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info, &cfgs[it], rt_format_desc))
2427 {
2428 if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, &cfgs[it], ds_format_desc))
2429 {
2430 TRACE_(d3d_caps)("(%p) : Formats matched\n", This);
2431 return WINED3D_OK;
2432 }
2433 }
2434 }
2435 WARN_(d3d_caps)("unsupported format pair: %s and %s\n", debug_d3dformat(RenderTargetFormat), debug_d3dformat(DepthStencilFormat));
2436
2437 return WINED3DERR_NOTAVAILABLE;
2438}
2439
2440static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
2441 WINED3DFORMAT SurfaceFormat, BOOL Windowed, WINED3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels)
2442{
2443 IWineD3DImpl *This = (IWineD3DImpl *)iface;
2444 const struct GlPixelFormatDesc *glDesc;
2445 const struct WineD3DAdapter *adapter;
2446
2447 TRACE_(d3d_caps)("(%p)-> (Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x, pQual:%p)\n",
2448 This,
2449 Adapter,
2450 DeviceType, debug_d3ddevicetype(DeviceType),
2451 SurfaceFormat, debug_d3dformat(SurfaceFormat),
2452 Windowed,
2453 MultiSampleType,
2454 pQualityLevels);
2455
2456 if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
2457 return WINED3DERR_INVALIDCALL;
2458 }
2459
2460 /* TODO: handle Windowed, add more quality levels */
2461
2462 if (WINED3DMULTISAMPLE_NONE == MultiSampleType) {
2463 if(pQualityLevels) *pQualityLevels = 1;
2464 return WINED3D_OK;
2465 }
2466
2467 /* By default multisampling is disabled right now as it causes issues
2468 * on some Nvidia driver versions and it doesn't work well in combination
2469 * with FBOs yet. */
2470 if(!wined3d_settings.allow_multisampling)
2471 return WINED3DERR_NOTAVAILABLE;
2472
2473 adapter = &This->adapters[Adapter];
2474 glDesc = getFormatDescEntry(SurfaceFormat, &adapter->gl_info);
2475 if (!glDesc) return WINED3DERR_INVALIDCALL;
2476
2477 if(glDesc->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) {
2478 int i, nCfgs;
2479 const WineD3D_PixelFormat *cfgs;
2480
2481 cfgs = adapter->cfgs;
2482 nCfgs = adapter->nCfgs;
2483 for(i=0; i<nCfgs; i++) {
2484 if(cfgs[i].numSamples != MultiSampleType)
2485 continue;
2486
2487 if (!IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, &cfgs[i], glDesc))
2488 continue;
2489
2490 TRACE("Found iPixelFormat=%d to support MultiSampleType=%d for format %s\n", cfgs[i].iPixelFormat, MultiSampleType, debug_d3dformat(SurfaceFormat));
2491
2492 if(pQualityLevels)
2493 *pQualityLevels = 1; /* Guess at a value! */
2494 return WINED3D_OK;
2495 }
2496 }
2497 else if(glDesc->Flags & WINED3DFMT_FLAG_RENDERTARGET) {
2498 short redSize, greenSize, blueSize, alphaSize, colorBits;
2499 int i, nCfgs;
2500 const WineD3D_PixelFormat *cfgs;
2501
2502 if (!getColorBits(glDesc, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits))
2503 {
2504 ERR("Unable to color bits for format %#x, can't check multisampling capability!\n", SurfaceFormat);
2505 return WINED3DERR_NOTAVAILABLE;
2506 }
2507
2508 cfgs = adapter->cfgs;
2509 nCfgs = adapter->nCfgs;
2510 for(i=0; i<nCfgs; i++) {
2511 if(cfgs[i].numSamples != MultiSampleType)
2512 continue;
2513 if(cfgs[i].redSize != redSize)
2514 continue;
2515 if(cfgs[i].greenSize != greenSize)
2516 continue;
2517 if(cfgs[i].blueSize != blueSize)
2518 continue;
2519 if(cfgs[i].alphaSize != alphaSize)
2520 continue;
2521
2522 TRACE("Found iPixelFormat=%d to support MultiSampleType=%d for format %s\n", cfgs[i].iPixelFormat, MultiSampleType, debug_d3dformat(SurfaceFormat));
2523
2524 if(pQualityLevels)
2525 *pQualityLevels = 1; /* Guess at a value! */
2526 return WINED3D_OK;
2527 }
2528 }
2529 return WINED3DERR_NOTAVAILABLE;
2530}
2531
2532static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
2533 WINED3DFORMAT DisplayFormat, WINED3DFORMAT BackBufferFormat, BOOL Windowed) {
2534
2535 IWineD3DImpl *This = (IWineD3DImpl *)iface;
2536 HRESULT hr = WINED3DERR_NOTAVAILABLE;
2537 UINT nmodes;
2538
2539 TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, CheckType:(%x,%s), DispFmt:(%x,%s), BackBuf:(%x,%s), Win?%d): stub\n",
2540 This,
2541 Adapter,
2542 DeviceType, debug_d3ddevicetype(DeviceType),
2543 DisplayFormat, debug_d3dformat(DisplayFormat),
2544 BackBufferFormat, debug_d3dformat(BackBufferFormat),
2545 Windowed);
2546
2547 if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
2548 WARN_(d3d_caps)("Adapter >= IWineD3D_GetAdapterCount(iface), returning WINED3DERR_INVALIDCALL\n");
2549 return WINED3DERR_INVALIDCALL;
2550 }
2551
2552 /* The task of this function is to check whether a certain display / backbuffer format
2553 * combination is available on the given adapter. In fullscreen mode microsoft specified
2554 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
2555 * and display format should match exactly.
2556 * In windowed mode format conversion can occur and this depends on the driver. When format
2557 * conversion is done, this function should nevertheless fail and applications need to use
2558 * CheckDeviceFormatConversion.
2559 * At the moment we assume that fullscreen and windowed have the same capabilities */
2560
2561 /* There are only 4 display formats */
2562 if (!(DisplayFormat == WINED3DFMT_B5G6R5_UNORM
2563 || DisplayFormat == WINED3DFMT_B5G5R5X1_UNORM
2564 || DisplayFormat == WINED3DFMT_B8G8R8X8_UNORM
2565 || DisplayFormat == WINED3DFMT_B10G10R10A2_UNORM))
2566 {
2567 TRACE_(d3d_caps)("Format %s unsupported as display format\n", debug_d3dformat(DisplayFormat));
2568 return WINED3DERR_NOTAVAILABLE;
2569 }
2570
2571 /* If the requested DisplayFormat is not available, don't continue */
2572 nmodes = IWineD3DImpl_GetAdapterModeCount(iface, Adapter, DisplayFormat);
2573 if(!nmodes) {
2574 TRACE_(d3d_caps)("No available modes for display format %s\n", debug_d3dformat(DisplayFormat));
2575 return WINED3DERR_NOTAVAILABLE;
2576 }
2577
2578 /* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbufferformat, it means 'reuse' the display format for the backbuffer */
2579 if(!Windowed && BackBufferFormat == WINED3DFMT_UNKNOWN) {
2580 TRACE_(d3d_caps)("BackBufferFormat WINED3FMT_UNKNOWN not available in Windowed mode\n");
2581 return WINED3DERR_NOTAVAILABLE;
2582 }
2583
2584 /* In FULLSCREEN mode R5G6B5 can only be mixed with backbuffer format R5G6B5 */
2585 if (DisplayFormat == WINED3DFMT_B5G6R5_UNORM && BackBufferFormat != WINED3DFMT_B5G6R5_UNORM)
2586 {
2587 TRACE_(d3d_caps)("Unsupported display/backbuffer format combination %s/%s\n", debug_d3dformat(DisplayFormat), debug_d3dformat(BackBufferFormat));
2588 return WINED3DERR_NOTAVAILABLE;
2589 }
2590
2591 /* In FULLSCREEN mode X1R5G5B5 can only be mixed with backbuffer format *1R5G5B5 */
2592 if (DisplayFormat == WINED3DFMT_B5G5R5X1_UNORM
2593 && !(BackBufferFormat == WINED3DFMT_B5G5R5X1_UNORM || BackBufferFormat == WINED3DFMT_B5G5R5A1_UNORM))
2594 {
2595 TRACE_(d3d_caps)("Unsupported display/backbuffer format combination %s/%s\n", debug_d3dformat(DisplayFormat), debug_d3dformat(BackBufferFormat));
2596 return WINED3DERR_NOTAVAILABLE;
2597 }
2598
2599 /* In FULLSCREEN mode X8R8G8B8 can only be mixed with backbuffer format *8R8G8B8 */
2600 if (DisplayFormat == WINED3DFMT_B8G8R8X8_UNORM
2601 && !(BackBufferFormat == WINED3DFMT_B8G8R8X8_UNORM || BackBufferFormat == WINED3DFMT_B8G8R8A8_UNORM))
2602 {
2603 TRACE_(d3d_caps)("Unsupported display/backbuffer format combination %s/%s\n", debug_d3dformat(DisplayFormat), debug_d3dformat(BackBufferFormat));
2604 return WINED3DERR_NOTAVAILABLE;
2605 }
2606
2607 /* A2R10G10B10 is only allowed in fullscreen mode and it can only be mixed with backbuffer format A2R10G10B10 */
2608 if (DisplayFormat == WINED3DFMT_B10G10R10A2_UNORM
2609 && (BackBufferFormat != WINED3DFMT_B10G10R10A2_UNORM || Windowed))
2610 {
2611 TRACE_(d3d_caps)("Unsupported display/backbuffer format combination %s/%s\n", debug_d3dformat(DisplayFormat), debug_d3dformat(BackBufferFormat));
2612 return WINED3DERR_NOTAVAILABLE;
2613 }
2614
2615 /* Use CheckDeviceFormat to see if the BackBufferFormat is usable with the given DisplayFormat */
2616 hr = IWineD3DImpl_CheckDeviceFormat(iface, Adapter, DeviceType, DisplayFormat, WINED3DUSAGE_RENDERTARGET, WINED3DRTYPE_SURFACE, BackBufferFormat, SURFACE_OPENGL);
2617 if(FAILED(hr))
2618 TRACE_(d3d_caps)("Unsupported display/backbuffer format combination %s/%s\n", debug_d3dformat(DisplayFormat), debug_d3dformat(BackBufferFormat));
2619
2620 return hr;
2621}
2622
2623
2624/* Check if we support bumpmapping for a format */
2625static BOOL CheckBumpMapCapability(struct WineD3DAdapter *adapter,
2626 WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *format_desc)
2627{
2628 const struct fragment_pipeline *fp;
2629
2630 switch(format_desc->format)
2631 {
2632 case WINED3DFMT_R8G8_SNORM:
2633 case WINED3DFMT_R16G16_SNORM:
2634 case WINED3DFMT_R5G5_SNORM_L6_UNORM:
2635 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
2636 case WINED3DFMT_R8G8B8A8_SNORM:
2637 /* Ask the fixed function pipeline implementation if it can deal
2638 * with the conversion. If we've got a GL extension giving native
2639 * support this will be an identity conversion. */
2640 fp = select_fragment_implementation(adapter, DeviceType);
2641 if (fp->color_fixup_supported(format_desc->color_fixup))
2642 {
2643 TRACE_(d3d_caps)("[OK]\n");
2644 return TRUE;
2645 }
2646 TRACE_(d3d_caps)("[FAILED]\n");
2647 return FALSE;
2648
2649 default:
2650 TRACE_(d3d_caps)("[FAILED]\n");
2651 return FALSE;
2652 }
2653}
2654
2655/* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
2656static BOOL CheckDepthStencilCapability(struct WineD3DAdapter *adapter,
2657 const struct GlPixelFormatDesc *display_format_desc, const struct GlPixelFormatDesc *ds_format_desc)
2658{
2659 int it=0;
2660
2661 /* Only allow depth/stencil formats */
2662 if (!(ds_format_desc->depth_size || ds_format_desc->stencil_size)) return FALSE;
2663
2664 /* Walk through all WGL pixel formats to find a match */
2665 for (it = 0; it < adapter->nCfgs; ++it)
2666 {
2667 WineD3D_PixelFormat *cfg = &adapter->cfgs[it];
2668 if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info, cfg, display_format_desc))
2669 {
2670 if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, cfg, ds_format_desc))
2671 {
2672 return TRUE;
2673 }
2674 }
2675 }
2676
2677 return FALSE;
2678}
2679
2680static BOOL CheckFilterCapability(struct WineD3DAdapter *adapter, const struct GlPixelFormatDesc *format_desc)
2681{
2682 /* The flags entry of a format contains the filtering capability */
2683 if (format_desc->Flags & WINED3DFMT_FLAG_FILTERING) return TRUE;
2684
2685 return FALSE;
2686}
2687
2688/* Check the render target capabilities of a format */
2689static BOOL CheckRenderTargetCapability(struct WineD3DAdapter *adapter,
2690 const struct GlPixelFormatDesc *adapter_format_desc, const struct GlPixelFormatDesc *check_format_desc)
2691{
2692 /* Filter out non-RT formats */
2693 if (!(check_format_desc->Flags & WINED3DFMT_FLAG_RENDERTARGET)) return FALSE;
2694
2695 if(wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER) {
2696 WineD3D_PixelFormat *cfgs = adapter->cfgs;
2697 int it;
2698 short AdapterRed, AdapterGreen, AdapterBlue, AdapterAlpha, AdapterTotalSize;
2699 short CheckRed, CheckGreen, CheckBlue, CheckAlpha, CheckTotalSize;
2700
2701 getColorBits(adapter_format_desc, &AdapterRed, &AdapterGreen, &AdapterBlue, &AdapterAlpha, &AdapterTotalSize);
2702 getColorBits(check_format_desc, &CheckRed, &CheckGreen, &CheckBlue, &CheckAlpha, &CheckTotalSize);
2703
2704 /* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
2705 * The format must match in RGB, alpha is allowed to be different. (Only the backbuffer can have alpha) */
2706 if(!((AdapterRed == CheckRed) && (AdapterGreen == CheckGreen) && (AdapterBlue == CheckBlue))) {
2707 TRACE_(d3d_caps)("[FAILED]\n");
2708 return FALSE;
2709 }
2710
2711 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
2712 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
2713 for (it = 0; it < adapter->nCfgs; ++it)
2714 {
2715 if (cfgs[it].windowDrawable && IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info,
2716 &cfgs[it], check_format_desc))
2717 {
2718 TRACE_(d3d_caps)("iPixelFormat=%d is compatible with CheckFormat=%s\n",
2719 cfgs[it].iPixelFormat, debug_d3dformat(check_format_desc->format));
2720 return TRUE;
2721 }
2722 }
2723 } else if(wined3d_settings.offscreen_rendering_mode == ORM_PBUFFER) {
2724 /* We can probably use this function in FBO mode too on some drivers to get some basic indication of the capabilities. */
2725 WineD3D_PixelFormat *cfgs = adapter->cfgs;
2726 int it;
2727
2728 /* Check if there is a WGL pixel format matching the requirements, the pixel format should also be usable with pbuffers */
2729 for (it = 0; it < adapter->nCfgs; ++it)
2730 {
2731 if (cfgs[it].pbufferDrawable && IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info,
2732 &cfgs[it], check_format_desc))
2733 {
2734 TRACE_(d3d_caps)("iPixelFormat=%d is compatible with CheckFormat=%s\n",
2735 cfgs[it].iPixelFormat, debug_d3dformat(check_format_desc->format));
2736 return TRUE;
2737 }
2738 }
2739 } else if(wined3d_settings.offscreen_rendering_mode == ORM_FBO){
2740 /* For now return TRUE for FBOs until we have some proper checks.
2741 * Note that this function will only be called when the format is around for texturing. */
2742 return TRUE;
2743 }
2744 return FALSE;
2745}
2746
2747static BOOL CheckSrgbReadCapability(struct WineD3DAdapter *adapter, const struct GlPixelFormatDesc *format_desc)
2748{
2749 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
2750
2751 /* Check for supported sRGB formats (Texture loading and framebuffer) */
2752 if(!GL_SUPPORT(EXT_TEXTURE_SRGB)) {
2753 TRACE_(d3d_caps)("[FAILED] GL_EXT_texture_sRGB not supported\n");
2754 return FALSE;
2755 }
2756
2757 switch (format_desc->format)
2758 {
2759 case WINED3DFMT_B8G8R8A8_UNORM:
2760 case WINED3DFMT_B8G8R8X8_UNORM:
2761 case WINED3DFMT_B4G4R4A4_UNORM:
2762 case WINED3DFMT_L8_UNORM:
2763 case WINED3DFMT_L8A8_UNORM:
2764 case WINED3DFMT_DXT1:
2765 case WINED3DFMT_DXT2:
2766 case WINED3DFMT_DXT3:
2767 case WINED3DFMT_DXT4:
2768 case WINED3DFMT_DXT5:
2769 TRACE_(d3d_caps)("[OK]\n");
2770 return TRUE;
2771
2772 default:
2773 TRACE_(d3d_caps)("[FAILED] Gamma texture format %s not supported.\n", debug_d3dformat(format_desc->format));
2774 return FALSE;
2775 }
2776 return FALSE;
2777}
2778
2779static BOOL CheckSrgbWriteCapability(struct WineD3DAdapter *adapter,
2780 WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *format_desc)
2781{
2782 /* Only offer SRGB writing on X8R8G8B8/A8R8G8B8 when we use ARB or GLSL shaders as we are
2783 * doing the color fixup in shaders.
2784 * Note Windows drivers (at least on the Geforce 8800) also offer this on R5G6B5. */
2785 if ((format_desc->format == WINED3DFMT_B8G8R8X8_UNORM) || (format_desc->format == WINED3DFMT_B8G8R8A8_UNORM))
2786 {
2787 int vs_selected_mode;
2788 int ps_selected_mode;
2789 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
2790
2791 if((ps_selected_mode == SHADER_ARB) || (ps_selected_mode == SHADER_GLSL)) {
2792 TRACE_(d3d_caps)("[OK]\n");
2793 return TRUE;
2794 }
2795 }
2796
2797 TRACE_(d3d_caps)("[FAILED] - no SRGB writing support on format=%s\n", debug_d3dformat(format_desc->format));
2798 return FALSE;
2799}
2800
2801/* Check if a format support blending in combination with pixel shaders */
2802static BOOL CheckPostPixelShaderBlendingCapability(struct WineD3DAdapter *adapter,
2803 const struct GlPixelFormatDesc *format_desc)
2804{
2805 /* The flags entry of a format contains the post pixel shader blending capability */
2806 if (format_desc->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING) return TRUE;
2807
2808 return FALSE;
2809}
2810
2811static BOOL CheckWrapAndMipCapability(struct WineD3DAdapter *adapter, const struct GlPixelFormatDesc *format_desc)
2812{
2813 /* OpenGL supports mipmapping on all formats basically. Wrapping is unsupported,
2814 * but we have to report mipmapping so we cannot reject this flag. Tests show that
2815 * windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to show
2816 * that wrapping is supported. The lack of filtering will sort out the mipmapping
2817 * capability anyway.
2818 *
2819 * For now lets report this on all formats, but in the future we may want to
2820 * restrict it to some should games need that
2821 */
2822 return TRUE;
2823}
2824
2825/* Check if a texture format is supported on the given adapter */
2826static BOOL CheckTextureCapability(struct WineD3DAdapter *adapter,
2827 WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *format_desc)
2828{
2829 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
2830 const shader_backend_t *shader_backend;
2831 const struct fragment_pipeline *fp;
2832
2833 switch (format_desc->format)
2834 {
2835 /*****
2836 * supported: RGB(A) formats
2837 */
2838 case WINED3DFMT_B8G8R8_UNORM: /* Enable for dx7, blacklisted for 8 and 9 above */
2839 case WINED3DFMT_B8G8R8A8_UNORM:
2840 case WINED3DFMT_B8G8R8X8_UNORM:
2841 case WINED3DFMT_B5G6R5_UNORM:
2842 case WINED3DFMT_B5G5R5X1_UNORM:
2843 case WINED3DFMT_B5G5R5A1_UNORM:
2844 case WINED3DFMT_B4G4R4A4_UNORM:
2845 case WINED3DFMT_A8_UNORM:
2846 case WINED3DFMT_B4G4R4X4_UNORM:
2847 case WINED3DFMT_R8G8B8A8_UNORM:
2848 case WINED3DFMT_R8G8B8X8_UNORM:
2849 case WINED3DFMT_B10G10R10A2_UNORM:
2850 case WINED3DFMT_R10G10B10A2_UNORM:
2851 case WINED3DFMT_R16G16_UNORM:
2852 TRACE_(d3d_caps)("[OK]\n");
2853 return TRUE;
2854
2855 case WINED3DFMT_B2G3R3_UNORM:
2856 TRACE_(d3d_caps)("[FAILED] - Not supported on Windows\n");
2857 return FALSE;
2858
2859 /*****
2860 * supported: Palettized
2861 */
2862 case WINED3DFMT_P8_UINT:
2863 TRACE_(d3d_caps)("[OK]\n");
2864 return TRUE;
2865 /* No Windows driver offers WINED3DFMT_P8_UINT_A8_UNORM, so don't offer it either */
2866 case WINED3DFMT_P8_UINT_A8_UNORM:
2867 return FALSE;
2868
2869 /*****
2870 * Supported: (Alpha)-Luminance
2871 */
2872 case WINED3DFMT_L8_UNORM:
2873 case WINED3DFMT_L8A8_UNORM:
2874 case WINED3DFMT_L16_UNORM:
2875 TRACE_(d3d_caps)("[OK]\n");
2876 return TRUE;
2877
2878 /* Not supported on Windows, thus disabled */
2879 case WINED3DFMT_L4A4_UNORM:
2880 TRACE_(d3d_caps)("[FAILED] - not supported on windows\n");
2881 return FALSE;
2882
2883 /*****
2884 * Supported: Depth/Stencil formats
2885 */
2886 case WINED3DFMT_D16_LOCKABLE:
2887 case WINED3DFMT_D16_UNORM:
2888 case WINED3DFMT_S1_UINT_D15_UNORM:
2889 case WINED3DFMT_X8D24_UNORM:
2890 case WINED3DFMT_S4X4_UINT_D24_UNORM:
2891 case WINED3DFMT_S8_UINT_D24_UNORM:
2892 case WINED3DFMT_S8_UINT_D24_FLOAT:
2893 case WINED3DFMT_D32_UNORM:
2894 case WINED3DFMT_D32_FLOAT:
2895 return TRUE;
2896
2897 /*****
2898 * Not supported everywhere(depends on GL_ATI_envmap_bumpmap or
2899 * GL_NV_texture_shader). Emulated by shaders
2900 */
2901 case WINED3DFMT_R8G8_SNORM:
2902 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
2903 case WINED3DFMT_R5G5_SNORM_L6_UNORM:
2904 case WINED3DFMT_R8G8B8A8_SNORM:
2905 case WINED3DFMT_R16G16_SNORM:
2906 /* Ask the shader backend if it can deal with the conversion. If
2907 * we've got a GL extension giving native support this will be an
2908 * identity conversion. */
2909 shader_backend = select_shader_backend(adapter, DeviceType);
2910 if (shader_backend->shader_color_fixup_supported(format_desc->color_fixup))
2911 {
2912 TRACE_(d3d_caps)("[OK]\n");
2913 return TRUE;
2914 }
2915 TRACE_(d3d_caps)("[FAILED]\n");
2916 return FALSE;
2917
2918 case WINED3DFMT_DXT1:
2919 case WINED3DFMT_DXT2:
2920 case WINED3DFMT_DXT3:
2921 case WINED3DFMT_DXT4:
2922 case WINED3DFMT_DXT5:
2923 if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
2924 TRACE_(d3d_caps)("[OK]\n");
2925 return TRUE;
2926 }
2927 TRACE_(d3d_caps)("[FAILED]\n");
2928 return FALSE;
2929
2930
2931 /*****
2932 * Odd formats - not supported
2933 */
2934 case WINED3DFMT_VERTEXDATA:
2935 case WINED3DFMT_R16_UINT:
2936 case WINED3DFMT_R32_UINT:
2937 case WINED3DFMT_R16G16B16A16_SNORM:
2938 case WINED3DFMT_R10G10B10_SNORM_A2_UNORM:
2939 case WINED3DFMT_R10G11B11_SNORM:
2940 TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
2941 return FALSE;
2942
2943 /*****
2944 * WINED3DFMT_R8G8_SNORM_Cx: Not supported right now
2945 */
2946 case WINED3DFMT_R8G8_SNORM_Cx:
2947 TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
2948 return FALSE;
2949
2950 /* YUV formats */
2951 case WINED3DFMT_UYVY:
2952 case WINED3DFMT_YUY2:
2953 if(GL_SUPPORT(APPLE_YCBCR_422)) {
2954 TRACE_(d3d_caps)("[OK]\n");
2955 return TRUE;
2956 }
2957 TRACE_(d3d_caps)("[FAILED]\n");
2958 return FALSE;
2959 case WINED3DFMT_YV12:
2960 TRACE_(d3d_caps)("[FAILED]\n");
2961 return FALSE;
2962
2963 /* Not supported */
2964 case WINED3DFMT_R16G16B16A16_UNORM:
2965 case WINED3DFMT_B2G3R3A8_UNORM:
2966 TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
2967 return FALSE;
2968
2969 /* Floating point formats */
2970 case WINED3DFMT_R16_FLOAT:
2971 case WINED3DFMT_R16G16_FLOAT:
2972 case WINED3DFMT_R16G16B16A16_FLOAT:
2973 if(GL_SUPPORT(ARB_TEXTURE_FLOAT) && GL_SUPPORT(ARB_HALF_FLOAT_PIXEL)) {
2974 TRACE_(d3d_caps)("[OK]\n");
2975 return TRUE;
2976 }
2977 TRACE_(d3d_caps)("[FAILED]\n");
2978 return FALSE;
2979
2980 case WINED3DFMT_R32_FLOAT:
2981 case WINED3DFMT_R32G32_FLOAT:
2982 case WINED3DFMT_R32G32B32A32_FLOAT:
2983 if (GL_SUPPORT(ARB_TEXTURE_FLOAT)) {
2984 TRACE_(d3d_caps)("[OK]\n");
2985 return TRUE;
2986 }
2987 TRACE_(d3d_caps)("[FAILED]\n");
2988 return FALSE;
2989
2990 /* ATI instancing hack: Although ATI cards do not support Shader Model 3.0, they support
2991 * instancing. To query if the card supports instancing CheckDeviceFormat with the special format
2992 * MAKEFOURCC('I','N','S','T') is used. Should a (broken) app check for this provide a proper return value.
2993 * We can do instancing with all shader versions, but we need vertex shaders.
2994 *
2995 * Additionally applications have to set the D3DRS_POINTSIZE render state to MAKEFOURCC('I','N','S','T') once
2996 * to enable instancing. WineD3D doesn't need that and just ignores it.
2997 *
2998 * With Shader Model 3.0 capable cards Instancing 'just works' in Windows.
2999 */
3000 case WINEMAKEFOURCC('I','N','S','T'):
3001 TRACE("ATI Instancing check hack\n");
3002 if(GL_SUPPORT(ARB_VERTEX_PROGRAM) || GL_SUPPORT(ARB_VERTEX_SHADER)) {
3003 TRACE_(d3d_caps)("[OK]\n");
3004 return TRUE;
3005 }
3006 TRACE_(d3d_caps)("[FAILED]\n");
3007 return FALSE;
3008
3009 /* Some weird FOURCC formats */
3010 case WINED3DFMT_R8G8_B8G8:
3011 case WINED3DFMT_G8R8_G8B8:
3012 case WINED3DFMT_MULTI2_ARGB8:
3013 TRACE_(d3d_caps)("[FAILED]\n");
3014 return FALSE;
3015
3016 /* Vendor specific formats */
3017 case WINED3DFMT_ATI2N:
3018 if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC) || GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {
3019 shader_backend = select_shader_backend(adapter, DeviceType);
3020 fp = select_fragment_implementation(adapter, DeviceType);
3021 if (shader_backend->shader_color_fixup_supported(format_desc->color_fixup)
3022 && fp->color_fixup_supported(format_desc->color_fixup))
3023 {
3024 TRACE_(d3d_caps)("[OK]\n");
3025 return TRUE;
3026 }
3027
3028 TRACE_(d3d_caps)("[OK]\n");
3029 return TRUE;
3030 }
3031 TRACE_(d3d_caps)("[FAILED]\n");
3032 return FALSE;
3033
3034 case WINED3DFMT_NVHU:
3035 case WINED3DFMT_NVHS:
3036 /* These formats seem to be similar to the HILO formats in GL_NV_texture_shader. NVHU
3037 * is said to be GL_UNSIGNED_HILO16, NVHS GL_SIGNED_HILO16. Rumours say that d3d computes
3038 * a 3rd channel similarly to D3DFMT_CxV8U8(So NVHS could be called D3DFMT_CxV16U16).
3039 * ATI refused to support formats which can easilly be emulated with pixel shaders, so
3040 * Applications have to deal with not having NVHS and NVHU.
3041 */
3042 TRACE_(d3d_caps)("[FAILED]\n");
3043 return FALSE;
3044
3045 case WINED3DFMT_UNKNOWN:
3046 return FALSE;
3047
3048 default:
3049 ERR("Unhandled format=%s\n", debug_d3dformat(format_desc->format));
3050 break;
3051 }
3052 return FALSE;
3053}
3054
3055static BOOL CheckSurfaceCapability(struct WineD3DAdapter *adapter, const struct GlPixelFormatDesc *adapter_format_desc,
3056 WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *check_format_desc, WINED3DSURFTYPE SurfaceType)
3057{
3058 const struct blit_shader *blitter;
3059
3060 if(SurfaceType == SURFACE_GDI) {
3061 switch(check_format_desc->format)
3062 {
3063 case WINED3DFMT_B8G8R8_UNORM:
3064 case WINED3DFMT_B8G8R8A8_UNORM:
3065 case WINED3DFMT_B8G8R8X8_UNORM:
3066 case WINED3DFMT_B5G6R5_UNORM:
3067 case WINED3DFMT_B5G5R5X1_UNORM:
3068 case WINED3DFMT_B5G5R5A1_UNORM:
3069 case WINED3DFMT_B4G4R4A4_UNORM:
3070 case WINED3DFMT_B2G3R3_UNORM:
3071 case WINED3DFMT_A8_UNORM:
3072 case WINED3DFMT_B2G3R3A8_UNORM:
3073 case WINED3DFMT_B4G4R4X4_UNORM:
3074 case WINED3DFMT_R10G10B10A2_UNORM:
3075 case WINED3DFMT_R8G8B8A8_UNORM:
3076 case WINED3DFMT_R8G8B8X8_UNORM:
3077 case WINED3DFMT_R16G16_UNORM:
3078 case WINED3DFMT_B10G10R10A2_UNORM:
3079 case WINED3DFMT_R16G16B16A16_UNORM:
3080 case WINED3DFMT_P8_UINT:
3081 TRACE_(d3d_caps)("[OK]\n");
3082 return TRUE;
3083 default:
3084 TRACE_(d3d_caps)("[FAILED] - not available on GDI surfaces\n");
3085 return FALSE;
3086 }
3087 }
3088
3089 /* All format that are supported for textures are supported for surfaces as well */
3090 if (CheckTextureCapability(adapter, DeviceType, check_format_desc)) return TRUE;
3091 /* All depth stencil formats are supported on surfaces */
3092 if (CheckDepthStencilCapability(adapter, adapter_format_desc, check_format_desc)) return TRUE;
3093
3094 /* If opengl can't process the format natively, the blitter may be able to convert it */
3095 blitter = select_blit_implementation(adapter, DeviceType);
3096 if (blitter->color_fixup_supported(check_format_desc->color_fixup))
3097 {
3098 TRACE_(d3d_caps)("[OK]\n");
3099 return TRUE;
3100 }
3101
3102 /* Reject other formats */
3103 TRACE_(d3d_caps)("[FAILED]\n");
3104 return FALSE;
3105}
3106
3107static BOOL CheckVertexTextureCapability(struct WineD3DAdapter *adapter, const struct GlPixelFormatDesc *format_desc)
3108{
3109 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
3110
3111 if (!GL_LIMITS(vertex_samplers)) {
3112 TRACE_(d3d_caps)("[FAILED]\n");
3113 return FALSE;
3114 }
3115
3116 switch (format_desc->format)
3117 {
3118 case WINED3DFMT_R32G32B32A32_FLOAT:
3119 if (!GL_SUPPORT(ARB_TEXTURE_FLOAT)) {
3120 TRACE_(d3d_caps)("[FAILED]\n");
3121 return FALSE;
3122 }
3123 TRACE_(d3d_caps)("[OK]\n");
3124 return TRUE;
3125
3126 default:
3127 TRACE_(d3d_caps)("[FAILED]\n");
3128 return FALSE;
3129 }
3130 return FALSE;
3131}
3132
3133static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
3134 WINED3DFORMAT AdapterFormat, DWORD Usage, WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat,
3135 WINED3DSURFTYPE SurfaceType)
3136{
3137 IWineD3DImpl *This = (IWineD3DImpl *)iface;
3138 struct WineD3DAdapter *adapter = &This->adapters[Adapter];
3139 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
3140 const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(CheckFormat, gl_info);
3141 const struct GlPixelFormatDesc *adapter_format_desc = getFormatDescEntry(AdapterFormat, gl_info);
3142 DWORD UsageCaps = 0;
3143
3144 TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), AdptFmt:(%u,%s), Use:(%u,%s,%s), ResTyp:(%x,%s), CheckFmt:(%u,%s))\n",
3145 This,
3146 Adapter,
3147 DeviceType, debug_d3ddevicetype(DeviceType),
3148 AdapterFormat, debug_d3dformat(AdapterFormat),
3149 Usage, debug_d3dusage(Usage), debug_d3dusagequery(Usage),
3150 RType, debug_d3dresourcetype(RType),
3151 CheckFormat, debug_d3dformat(CheckFormat));
3152
3153 if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
3154 return WINED3DERR_INVALIDCALL;
3155 }
3156
3157 if(RType == WINED3DRTYPE_CUBETEXTURE) {
3158
3159 if(SurfaceType != SURFACE_OPENGL) {
3160 TRACE("[FAILED]\n");
3161 return WINED3DERR_NOTAVAILABLE;
3162 }
3163
3164 /* Cubetexture allows:
3165 * - D3DUSAGE_AUTOGENMIPMAP
3166 * - D3DUSAGE_DEPTHSTENCIL
3167 * - D3DUSAGE_DYNAMIC
3168 * - D3DUSAGE_NONSECURE (d3d9ex)
3169 * - D3DUSAGE_RENDERTARGET
3170 * - D3DUSAGE_SOFTWAREPROCESSING
3171 * - D3DUSAGE_QUERY_WRAPANDMIP
3172 */
3173 if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
3174 /* Check if the texture format is around */
3175 if (CheckTextureCapability(adapter, DeviceType, format_desc))
3176 {
3177 if(Usage & WINED3DUSAGE_AUTOGENMIPMAP) {
3178 /* Check for automatic mipmap generation support */
3179 if(GL_SUPPORT(SGIS_GENERATE_MIPMAP)) {
3180 UsageCaps |= WINED3DUSAGE_AUTOGENMIPMAP;
3181 } else {
3182 /* When autogenmipmap isn't around continue and return WINED3DOK_NOAUTOGEN instead of D3D_OK */
3183 TRACE_(d3d_caps)("[FAILED] - No autogenmipmap support, but continuing\n");
3184 }
3185 }
3186
3187 /* Always report dynamic locking */
3188 if(Usage & WINED3DUSAGE_DYNAMIC)
3189 UsageCaps |= WINED3DUSAGE_DYNAMIC;
3190
3191 if(Usage & WINED3DUSAGE_RENDERTARGET) {
3192 if(CheckRenderTargetCapability(adapter, adapter_format_desc, format_desc))
3193 {
3194 UsageCaps |= WINED3DUSAGE_RENDERTARGET;
3195 } else {
3196 TRACE_(d3d_caps)("[FAILED] - No rendertarget support\n");
3197 return WINED3DERR_NOTAVAILABLE;
3198 }
3199 }
3200
3201 /* Always report software processing */
3202 if(Usage & WINED3DUSAGE_SOFTWAREPROCESSING)
3203 UsageCaps |= WINED3DUSAGE_SOFTWAREPROCESSING;
3204
3205 /* Check QUERY_FILTER support */
3206 if(Usage & WINED3DUSAGE_QUERY_FILTER) {
3207 if (CheckFilterCapability(adapter, format_desc))
3208 {
3209 UsageCaps |= WINED3DUSAGE_QUERY_FILTER;
3210 } else {
3211 TRACE_(d3d_caps)("[FAILED] - No query filter support\n");
3212 return WINED3DERR_NOTAVAILABLE;
3213 }
3214 }
3215
3216 /* Check QUERY_POSTPIXELSHADER_BLENDING support */
3217 if(Usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING) {
3218 if (CheckPostPixelShaderBlendingCapability(adapter, format_desc))
3219 {
3220 UsageCaps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
3221 } else {
3222 TRACE_(d3d_caps)("[FAILED] - No query post pixelshader blending support\n");
3223 return WINED3DERR_NOTAVAILABLE;
3224 }
3225 }
3226
3227 /* Check QUERY_SRGBREAD support */
3228 if(Usage & WINED3DUSAGE_QUERY_SRGBREAD) {
3229 if (CheckSrgbReadCapability(adapter, format_desc))
3230 {
3231 UsageCaps |= WINED3DUSAGE_QUERY_SRGBREAD;
3232 } else {
3233 TRACE_(d3d_caps)("[FAILED] - No query srgbread support\n");
3234 return WINED3DERR_NOTAVAILABLE;
3235 }
3236 }
3237
3238 /* Check QUERY_SRGBWRITE support */
3239 if(Usage & WINED3DUSAGE_QUERY_SRGBWRITE) {
3240 if (CheckSrgbWriteCapability(adapter, DeviceType, format_desc))
3241 {
3242 UsageCaps |= WINED3DUSAGE_QUERY_SRGBWRITE;
3243 } else {
3244 TRACE_(d3d_caps)("[FAILED] - No query srgbwrite support\n");
3245 return WINED3DERR_NOTAVAILABLE;
3246 }
3247 }
3248
3249 /* Check QUERY_VERTEXTEXTURE support */
3250 if(Usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE) {
3251 if (CheckVertexTextureCapability(adapter, format_desc))
3252 {
3253 UsageCaps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
3254 } else {
3255 TRACE_(d3d_caps)("[FAILED] - No query vertextexture support\n");
3256 return WINED3DERR_NOTAVAILABLE;
3257 }
3258 }
3259
3260 /* Check QUERY_WRAPANDMIP support */
3261 if(Usage & WINED3DUSAGE_QUERY_WRAPANDMIP) {
3262 if (CheckWrapAndMipCapability(adapter, format_desc))
3263 {
3264 UsageCaps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
3265 } else {
3266 TRACE_(d3d_caps)("[FAILED] - No wrapping and mipmapping support\n");
3267 return WINED3DERR_NOTAVAILABLE;
3268 }
3269 }
3270 } else {
3271 TRACE_(d3d_caps)("[FAILED] - Cube texture format not supported\n");
3272 return WINED3DERR_NOTAVAILABLE;
3273 }
3274 } else {
3275 TRACE_(d3d_caps)("[FAILED] - No cube texture support\n");
3276 return WINED3DERR_NOTAVAILABLE;
3277 }
3278 } else if(RType == WINED3DRTYPE_SURFACE) {
3279 /* Surface allows:
3280 * - D3DUSAGE_DEPTHSTENCIL
3281 * - D3DUSAGE_NONSECURE (d3d9ex)
3282 * - D3DUSAGE_RENDERTARGET
3283 */
3284
3285 if (CheckSurfaceCapability(adapter, adapter_format_desc, DeviceType, format_desc, SurfaceType))
3286 {
3287 if(Usage & WINED3DUSAGE_DEPTHSTENCIL) {
3288 if (CheckDepthStencilCapability(adapter, adapter_format_desc, format_desc))
3289 {
3290 UsageCaps |= WINED3DUSAGE_DEPTHSTENCIL;
3291 } else {
3292 TRACE_(d3d_caps)("[FAILED] - No depthstencil support\n");
3293 return WINED3DERR_NOTAVAILABLE;
3294 }
3295 }
3296
3297 if(Usage & WINED3DUSAGE_RENDERTARGET) {
3298 if (CheckRenderTargetCapability(adapter, adapter_format_desc, format_desc))
3299 {
3300 UsageCaps |= WINED3DUSAGE_RENDERTARGET;
3301 } else {
3302 TRACE_(d3d_caps)("[FAILED] - No rendertarget support\n");
3303 return WINED3DERR_NOTAVAILABLE;
3304 }
3305 }
3306
3307 /* Check QUERY_POSTPIXELSHADER_BLENDING support */
3308 if(Usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING) {
3309 if (CheckPostPixelShaderBlendingCapability(adapter, format_desc))
3310 {
3311 UsageCaps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
3312 } else {
3313 TRACE_(d3d_caps)("[FAILED] - No query post pixelshader blending support\n");
3314 return WINED3DERR_NOTAVAILABLE;
3315 }
3316 }
3317 } else {
3318 TRACE_(d3d_caps)("[FAILED] - Not supported for plain surfaces\n");
3319 return WINED3DERR_NOTAVAILABLE;
3320 }
3321
3322 } else if(RType == WINED3DRTYPE_TEXTURE) {
3323 /* Texture allows:
3324 * - D3DUSAGE_AUTOGENMIPMAP
3325 * - D3DUSAGE_DEPTHSTENCIL
3326 * - D3DUSAGE_DMAP
3327 * - D3DUSAGE_DYNAMIC
3328 * - D3DUSAGE_NONSECURE (d3d9ex)
3329 * - D3DUSAGE_RENDERTARGET
3330 * - D3DUSAGE_SOFTWAREPROCESSING
3331 * - D3DUSAGE_TEXTAPI (d3d9ex)
3332 * - D3DUSAGE_QUERY_WRAPANDMIP
3333 */
3334
3335 if(SurfaceType != SURFACE_OPENGL) {
3336 TRACE("[FAILED]\n");
3337 return WINED3DERR_NOTAVAILABLE;
3338 }
3339
3340 /* Check if the texture format is around */
3341 if (CheckTextureCapability(adapter, DeviceType, format_desc))
3342 {
3343 if(Usage & WINED3DUSAGE_AUTOGENMIPMAP) {
3344 /* Check for automatic mipmap generation support */
3345 if(GL_SUPPORT(SGIS_GENERATE_MIPMAP)) {
3346 UsageCaps |= WINED3DUSAGE_AUTOGENMIPMAP;
3347 } else {
3348 /* When autogenmipmap isn't around continue and return WINED3DOK_NOAUTOGEN instead of D3D_OK */
3349 TRACE_(d3d_caps)("[FAILED] - No autogenmipmap support, but continuing\n");
3350 }
3351 }
3352
3353 /* Always report dynamic locking */
3354 if(Usage & WINED3DUSAGE_DYNAMIC)
3355 UsageCaps |= WINED3DUSAGE_DYNAMIC;
3356
3357 if(Usage & WINED3DUSAGE_RENDERTARGET) {
3358 if (CheckRenderTargetCapability(adapter, adapter_format_desc, format_desc))
3359 {
3360 UsageCaps |= WINED3DUSAGE_RENDERTARGET;
3361 } else {
3362 TRACE_(d3d_caps)("[FAILED] - No rendertarget support\n");
3363 return WINED3DERR_NOTAVAILABLE;
3364 }
3365 }
3366
3367 /* Always report software processing */
3368 if(Usage & WINED3DUSAGE_SOFTWAREPROCESSING)
3369 UsageCaps |= WINED3DUSAGE_SOFTWAREPROCESSING;
3370
3371 /* Check QUERY_FILTER support */
3372 if(Usage & WINED3DUSAGE_QUERY_FILTER) {
3373 if (CheckFilterCapability(adapter, format_desc))
3374 {
3375 UsageCaps |= WINED3DUSAGE_QUERY_FILTER;
3376 } else {
3377 TRACE_(d3d_caps)("[FAILED] - No query filter support\n");
3378 return WINED3DERR_NOTAVAILABLE;
3379 }
3380 }
3381
3382 /* Check QUERY_LEGACYBUMPMAP support */
3383 if(Usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP) {
3384 if (CheckBumpMapCapability(adapter, DeviceType, format_desc))
3385 {
3386 UsageCaps |= WINED3DUSAGE_QUERY_LEGACYBUMPMAP;
3387 } else {
3388 TRACE_(d3d_caps)("[FAILED] - No legacy bumpmap support\n");
3389 return WINED3DERR_NOTAVAILABLE;
3390 }
3391 }
3392
3393 /* Check QUERY_POSTPIXELSHADER_BLENDING support */
3394 if(Usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING) {
3395 if (CheckPostPixelShaderBlendingCapability(adapter, format_desc))
3396 {
3397 UsageCaps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
3398 } else {
3399 TRACE_(d3d_caps)("[FAILED] - No query post pixelshader blending support\n");
3400 return WINED3DERR_NOTAVAILABLE;
3401 }
3402 }
3403
3404 /* Check QUERY_SRGBREAD support */
3405 if(Usage & WINED3DUSAGE_QUERY_SRGBREAD) {
3406 if (CheckSrgbReadCapability(adapter, format_desc))
3407 {
3408 UsageCaps |= WINED3DUSAGE_QUERY_SRGBREAD;
3409 } else {
3410 TRACE_(d3d_caps)("[FAILED] - No query srgbread support\n");
3411 return WINED3DERR_NOTAVAILABLE;
3412 }
3413 }
3414
3415 /* Check QUERY_SRGBWRITE support */
3416 if(Usage & WINED3DUSAGE_QUERY_SRGBWRITE) {
3417 if (CheckSrgbWriteCapability(adapter, DeviceType, format_desc))
3418 {
3419 UsageCaps |= WINED3DUSAGE_QUERY_SRGBWRITE;
3420 } else {
3421 TRACE_(d3d_caps)("[FAILED] - No query srgbwrite support\n");
3422 return WINED3DERR_NOTAVAILABLE;
3423 }
3424 }
3425
3426 /* Check QUERY_VERTEXTEXTURE support */
3427 if(Usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE) {
3428 if (CheckVertexTextureCapability(adapter, format_desc))
3429 {
3430 UsageCaps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
3431 } else {
3432 TRACE_(d3d_caps)("[FAILED] - No query vertextexture support\n");
3433 return WINED3DERR_NOTAVAILABLE;
3434 }
3435 }
3436
3437 /* Check QUERY_WRAPANDMIP support */
3438 if(Usage & WINED3DUSAGE_QUERY_WRAPANDMIP) {
3439 if (CheckWrapAndMipCapability(adapter, format_desc))
3440 {
3441 UsageCaps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
3442 } else {
3443 TRACE_(d3d_caps)("[FAILED] - No wrapping and mipmapping support\n");
3444 return WINED3DERR_NOTAVAILABLE;
3445 }
3446 }
3447
3448 if(Usage & WINED3DUSAGE_DEPTHSTENCIL) {
3449 if (CheckDepthStencilCapability(adapter, adapter_format_desc, format_desc))
3450 {
3451 UsageCaps |= WINED3DUSAGE_DEPTHSTENCIL;
3452 } else {
3453 TRACE_(d3d_caps)("[FAILED] - No depth stencil support\n");
3454 return WINED3DERR_NOTAVAILABLE;
3455 }
3456 }
3457 } else {
3458 TRACE_(d3d_caps)("[FAILED] - Texture format not supported\n");
3459 return WINED3DERR_NOTAVAILABLE;
3460 }
3461 } else if((RType == WINED3DRTYPE_VOLUME) || (RType == WINED3DRTYPE_VOLUMETEXTURE)) {
3462 /* Volume is to VolumeTexture what Surface is to Texture but its usage caps are not documented.
3463 * Most driver seem to offer (nearly) the same on Volume and VolumeTexture, so do that too.
3464 *
3465 * Volumetexture allows:
3466 * - D3DUSAGE_DYNAMIC
3467 * - D3DUSAGE_NONSECURE (d3d9ex)
3468 * - D3DUSAGE_SOFTWAREPROCESSING
3469 * - D3DUSAGE_QUERY_WRAPANDMIP
3470 */
3471
3472 if(SurfaceType != SURFACE_OPENGL) {
3473 TRACE("[FAILED]\n");
3474 return WINED3DERR_NOTAVAILABLE;
3475 }
3476
3477 /* Check volume texture and volume usage caps */
3478 if(GL_SUPPORT(EXT_TEXTURE3D)) {
3479 if (!CheckTextureCapability(adapter, DeviceType, format_desc))
3480 {
3481 TRACE_(d3d_caps)("[FAILED] - Format not supported\n");
3482 return WINED3DERR_NOTAVAILABLE;
3483 }
3484
3485 /* Always report dynamic locking */
3486 if(Usage & WINED3DUSAGE_DYNAMIC)
3487 UsageCaps |= WINED3DUSAGE_DYNAMIC;
3488
3489 /* Always report software processing */
3490 if(Usage & WINED3DUSAGE_SOFTWAREPROCESSING)
3491 UsageCaps |= WINED3DUSAGE_SOFTWAREPROCESSING;
3492
3493 /* Check QUERY_FILTER support */
3494 if(Usage & WINED3DUSAGE_QUERY_FILTER) {
3495 if (CheckFilterCapability(adapter, format_desc))
3496 {
3497 UsageCaps |= WINED3DUSAGE_QUERY_FILTER;
3498 } else {
3499 TRACE_(d3d_caps)("[FAILED] - No query filter support\n");
3500 return WINED3DERR_NOTAVAILABLE;
3501 }
3502 }
3503
3504 /* Check QUERY_POSTPIXELSHADER_BLENDING support */
3505 if(Usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING) {
3506 if (CheckPostPixelShaderBlendingCapability(adapter, format_desc))
3507 {
3508 UsageCaps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
3509 } else {
3510 TRACE_(d3d_caps)("[FAILED] - No query post pixelshader blending support\n");
3511 return WINED3DERR_NOTAVAILABLE;
3512 }
3513 }
3514
3515 /* Check QUERY_SRGBREAD support */
3516 if(Usage & WINED3DUSAGE_QUERY_SRGBREAD) {
3517 if (CheckSrgbReadCapability(adapter, format_desc))
3518 {
3519 UsageCaps |= WINED3DUSAGE_QUERY_SRGBREAD;
3520 } else {
3521 TRACE_(d3d_caps)("[FAILED] - No query srgbread support\n");
3522 return WINED3DERR_NOTAVAILABLE;
3523 }
3524 }
3525
3526 /* Check QUERY_SRGBWRITE support */
3527 if(Usage & WINED3DUSAGE_QUERY_SRGBWRITE) {
3528 if (CheckSrgbWriteCapability(adapter, DeviceType, format_desc))
3529 {
3530 UsageCaps |= WINED3DUSAGE_QUERY_SRGBWRITE;
3531 } else {
3532 TRACE_(d3d_caps)("[FAILED] - No query srgbwrite support\n");
3533 return WINED3DERR_NOTAVAILABLE;
3534 }
3535 }
3536
3537 /* Check QUERY_VERTEXTEXTURE support */
3538 if(Usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE) {
3539 if (CheckVertexTextureCapability(adapter, format_desc))
3540 {
3541 UsageCaps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
3542 } else {
3543 TRACE_(d3d_caps)("[FAILED] - No query vertextexture support\n");
3544 return WINED3DERR_NOTAVAILABLE;
3545 }
3546 }
3547
3548 /* Check QUERY_WRAPANDMIP support */
3549 if(Usage & WINED3DUSAGE_QUERY_WRAPANDMIP) {
3550 if (CheckWrapAndMipCapability(adapter, format_desc))
3551 {
3552 UsageCaps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
3553 } else {
3554 TRACE_(d3d_caps)("[FAILED] - No wrapping and mipmapping support\n");
3555 return WINED3DERR_NOTAVAILABLE;
3556 }
3557 }
3558 } else {
3559 TRACE_(d3d_caps)("[FAILED] - No volume texture support\n");
3560 return WINED3DERR_NOTAVAILABLE;
3561 }
3562
3563 /* Filter formats that need conversion; For one part, this conversion is unimplemented,
3564 * and volume textures are huge, so it would be a big performance hit. Unless we hit an
3565 * app needing one of those formats, don't advertize them to avoid leading apps into
3566 * temptation. The windows drivers don't support most of those formats on volumes anyway,
3567 * except of R32F.
3568 */
3569 switch(CheckFormat) {
3570 case WINED3DFMT_P8_UINT:
3571 case WINED3DFMT_L4A4_UNORM:
3572 case WINED3DFMT_R32_FLOAT:
3573 case WINED3DFMT_R16_FLOAT:
3574 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
3575 case WINED3DFMT_R5G5_SNORM_L6_UNORM:
3576 case WINED3DFMT_R16G16_UNORM:
3577 TRACE_(d3d_caps)("[FAILED] - No converted formats on volumes\n");
3578 return WINED3DERR_NOTAVAILABLE;
3579
3580 case WINED3DFMT_R8G8B8A8_SNORM:
3581 case WINED3DFMT_R16G16_SNORM:
3582 if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {
3583 TRACE_(d3d_caps)("[FAILED] - No converted formats on volumes\n");
3584 return WINED3DERR_NOTAVAILABLE;
3585 }
3586 break;
3587
3588 case WINED3DFMT_R8G8_SNORM:
3589 if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {
3590 TRACE_(d3d_caps)("[FAILED] - No converted formats on volumes\n");
3591 return WINED3DERR_NOTAVAILABLE;
3592 }
3593 break;
3594
3595 case WINED3DFMT_DXT1:
3596 case WINED3DFMT_DXT2:
3597 case WINED3DFMT_DXT3:
3598 case WINED3DFMT_DXT4:
3599 case WINED3DFMT_DXT5:
3600 /* The GL_EXT_texture_compression_s3tc spec requires that loading an s3tc
3601 * compressed texture results in an error. While the D3D refrast does
3602 * support s3tc volumes, at least the nvidia windows driver does not, so
3603 * we're free not to support this format.
3604 */
3605 TRACE_(d3d_caps)("[FAILED] - DXTn does not support 3D textures\n");
3606 return WINED3DERR_NOTAVAILABLE;
3607
3608 default:
3609 /* Do nothing, continue with checking the format below */
3610 break;
3611 }
3612 } else if(RType == WINED3DRTYPE_BUFFER){
3613 /* For instance vertexbuffer/indexbuffer aren't supported yet because no Windows drivers seem to offer it */
3614 TRACE_(d3d_caps)("Unhandled resource type D3DRTYPE_INDEXBUFFER / D3DRTYPE_VERTEXBUFFER\n");
3615 return WINED3DERR_NOTAVAILABLE;
3616 }
3617
3618 /* When the UsageCaps exactly matches Usage return WINED3D_OK except for the situation in which
3619 * WINED3DUSAGE_AUTOGENMIPMAP isn't around, then WINED3DOK_NOAUTOGEN is returned if all the other
3620 * usage flags match. */
3621 if(UsageCaps == Usage) {
3622 return WINED3D_OK;
3623 } else if((UsageCaps == (Usage & ~WINED3DUSAGE_AUTOGENMIPMAP)) && (Usage & WINED3DUSAGE_AUTOGENMIPMAP)){
3624 return WINED3DOK_NOAUTOGEN;
3625 } else {
3626 TRACE_(d3d_caps)("[FAILED] - Usage=%#08x requested for CheckFormat=%s and RType=%d but only %#08x is available\n", Usage, debug_d3dformat(CheckFormat), RType, UsageCaps);
3627 return WINED3DERR_NOTAVAILABLE;
3628 }
3629}
3630
3631static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
3632 WINED3DFORMAT SourceFormat, WINED3DFORMAT TargetFormat) {
3633 IWineD3DImpl *This = (IWineD3DImpl *)iface;
3634
3635 FIXME_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), SrcFmt:(%u,%s), TgtFmt:(%u,%s))\n",
3636 This,
3637 Adapter,
3638 DeviceType, debug_d3ddevicetype(DeviceType),
3639 SourceFormat, debug_d3dformat(SourceFormat),
3640 TargetFormat, debug_d3dformat(TargetFormat));
3641 return WINED3D_OK;
3642}
3643
3644static const shader_backend_t *select_shader_backend(struct WineD3DAdapter *adapter, WINED3DDEVTYPE DeviceType)
3645{
3646 const shader_backend_t *ret;
3647 int vs_selected_mode;
3648 int ps_selected_mode;
3649
3650 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
3651 if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) {
3652 ret = &glsl_shader_backend;
3653 } else if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) {
3654 ret = &arb_program_shader_backend;
3655 } else {
3656 ret = &none_shader_backend;
3657 }
3658 return ret;
3659}
3660
3661static const struct fragment_pipeline *select_fragment_implementation(struct WineD3DAdapter *adapter,
3662 WINED3DDEVTYPE DeviceType)
3663{
3664 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
3665 int vs_selected_mode;
3666 int ps_selected_mode;
3667
3668 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
3669 if((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) {
3670 return &arbfp_fragment_pipeline;
3671 } else if(ps_selected_mode == SHADER_ATI) {
3672 return &atifs_fragment_pipeline;
3673 } else if(GL_SUPPORT(NV_REGISTER_COMBINERS) && GL_SUPPORT(NV_TEXTURE_SHADER2)) {
3674 return &nvts_fragment_pipeline;
3675 } else if(GL_SUPPORT(NV_REGISTER_COMBINERS)) {
3676 return &nvrc_fragment_pipeline;
3677 } else {
3678 return &ffp_fragment_pipeline;
3679 }
3680}
3681
3682static const struct blit_shader *select_blit_implementation(struct WineD3DAdapter *adapter, WINED3DDEVTYPE DeviceType)
3683{
3684 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
3685 int vs_selected_mode;
3686 int ps_selected_mode;
3687
3688 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
3689 if((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) {
3690 return &arbfp_blit;
3691 } else {
3692 return &ffp_blit;
3693 }
3694}
3695
3696/* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
3697 subset of a D3DCAPS9 structure. However, it has to come via a void *
3698 as the d3d8 interface cannot import the d3d9 header */
3699static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType, WINED3DCAPS* pCaps) {
3700
3701 IWineD3DImpl *This = (IWineD3DImpl *)iface;
3702 struct WineD3DAdapter *adapter = &This->adapters[Adapter];
3703 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
3704 int vs_selected_mode;
3705 int ps_selected_mode;
3706 struct shader_caps shader_caps;
3707 struct fragment_caps fragment_caps;
3708 const shader_backend_t *shader_backend;
3709 const struct fragment_pipeline *frag_pipeline = NULL;
3710 DWORD ckey_caps, blit_caps, fx_caps;
3711
3712 TRACE_(d3d_caps)("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This, Adapter, DeviceType, pCaps);
3713
3714 if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
3715 return WINED3DERR_INVALIDCALL;
3716 }
3717
3718 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
3719
3720 /* This function should *not* be modifying GL caps
3721 * TODO: move the functionality where it belongs */
3722 select_shader_max_constants(ps_selected_mode, vs_selected_mode, &adapter->gl_info);
3723
3724 /* ------------------------------------------------
3725 The following fields apply to both d3d8 and d3d9
3726 ------------------------------------------------ */
3727 pCaps->DeviceType = (DeviceType == WINED3DDEVTYPE_HAL) ? WINED3DDEVTYPE_HAL : WINED3DDEVTYPE_REF; /* Not quite true, but use h/w supported by opengl I suppose */
3728 pCaps->AdapterOrdinal = Adapter;
3729
3730 pCaps->Caps = 0;
3731 pCaps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED |
3732 WINED3DCAPS2_FULLSCREENGAMMA |
3733 WINED3DCAPS2_DYNAMICTEXTURES;
3734 if(GL_SUPPORT(SGIS_GENERATE_MIPMAP)) {
3735 pCaps->Caps2 |= WINED3DCAPS2_CANAUTOGENMIPMAP;
3736 }
3737
3738 pCaps->Caps3 = WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD |
3739 WINED3DCAPS3_COPY_TO_VIDMEM |
3740 WINED3DCAPS3_COPY_TO_SYSTEMMEM;
3741
3742 pCaps->PresentationIntervals = WINED3DPRESENT_INTERVAL_IMMEDIATE |
3743 WINED3DPRESENT_INTERVAL_ONE;
3744
3745 pCaps->CursorCaps = WINED3DCURSORCAPS_COLOR |
3746 WINED3DCURSORCAPS_LOWRES;
3747
3748 pCaps->DevCaps = WINED3DDEVCAPS_FLOATTLVERTEX |
3749 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY |
3750 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY|
3751 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY |
3752 WINED3DDEVCAPS_DRAWPRIMTLVERTEX |
3753 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT |
3754 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY |
3755 WINED3DDEVCAPS_PUREDEVICE |
3756 WINED3DDEVCAPS_HWRASTERIZATION |
3757 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY |
3758 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY |
3759 WINED3DDEVCAPS_CANRENDERAFTERFLIP |
3760 WINED3DDEVCAPS_DRAWPRIMITIVES2 |
3761 WINED3DDEVCAPS_DRAWPRIMITIVES2EX |
3762 WINED3DDEVCAPS_RTPATCHES;
3763
3764 pCaps->PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE |
3765 WINED3DPMISCCAPS_CULLCCW |
3766 WINED3DPMISCCAPS_CULLCW |
3767 WINED3DPMISCCAPS_COLORWRITEENABLE |
3768 WINED3DPMISCCAPS_CLIPTLVERTS |
3769 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
3770 WINED3DPMISCCAPS_MASKZ |
3771 WINED3DPMISCCAPS_BLENDOP |
3772 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
3773 /* TODO:
3774 WINED3DPMISCCAPS_NULLREFERENCE
3775 WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS
3776 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
3777 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
3778 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
3779
3780 if(GL_SUPPORT(EXT_BLEND_EQUATION_SEPARATE) && GL_SUPPORT(EXT_BLEND_FUNC_SEPARATE))
3781 pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
3782
3783 pCaps->RasterCaps = WINED3DPRASTERCAPS_DITHER |
3784 WINED3DPRASTERCAPS_PAT |
3785 WINED3DPRASTERCAPS_WFOG |
3786 WINED3DPRASTERCAPS_ZFOG |
3787 WINED3DPRASTERCAPS_FOGVERTEX |
3788 WINED3DPRASTERCAPS_FOGTABLE |
3789 WINED3DPRASTERCAPS_STIPPLE |
3790 WINED3DPRASTERCAPS_SUBPIXEL |
3791 WINED3DPRASTERCAPS_ZTEST |
3792 WINED3DPRASTERCAPS_SCISSORTEST |
3793 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
3794 WINED3DPRASTERCAPS_DEPTHBIAS;
3795
3796 if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
3797 pCaps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY |
3798 WINED3DPRASTERCAPS_ZBIAS |
3799 WINED3DPRASTERCAPS_MIPMAPLODBIAS;
3800 }
3801 if(GL_SUPPORT(NV_FOG_DISTANCE)) {
3802 pCaps->RasterCaps |= WINED3DPRASTERCAPS_FOGRANGE;
3803 }
3804 /* FIXME Add:
3805 WINED3DPRASTERCAPS_COLORPERSPECTIVE
3806 WINED3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
3807 WINED3DPRASTERCAPS_ANTIALIASEDGES
3808 WINED3DPRASTERCAPS_ZBUFFERLESSHSR
3809 WINED3DPRASTERCAPS_WBUFFER */
3810
3811 pCaps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
3812 WINED3DPCMPCAPS_EQUAL |
3813 WINED3DPCMPCAPS_GREATER |
3814 WINED3DPCMPCAPS_GREATEREQUAL |
3815 WINED3DPCMPCAPS_LESS |
3816 WINED3DPCMPCAPS_LESSEQUAL |
3817 WINED3DPCMPCAPS_NEVER |
3818 WINED3DPCMPCAPS_NOTEQUAL;
3819
3820 pCaps->SrcBlendCaps = WINED3DPBLENDCAPS_BOTHINVSRCALPHA |
3821 WINED3DPBLENDCAPS_BOTHSRCALPHA |
3822 WINED3DPBLENDCAPS_DESTALPHA |
3823 WINED3DPBLENDCAPS_DESTCOLOR |
3824 WINED3DPBLENDCAPS_INVDESTALPHA |
3825 WINED3DPBLENDCAPS_INVDESTCOLOR |
3826 WINED3DPBLENDCAPS_INVSRCALPHA |
3827 WINED3DPBLENDCAPS_INVSRCCOLOR |
3828 WINED3DPBLENDCAPS_ONE |
3829 WINED3DPBLENDCAPS_SRCALPHA |
3830 WINED3DPBLENDCAPS_SRCALPHASAT |
3831 WINED3DPBLENDCAPS_SRCCOLOR |
3832 WINED3DPBLENDCAPS_ZERO;
3833
3834 pCaps->DestBlendCaps = WINED3DPBLENDCAPS_DESTALPHA |
3835 WINED3DPBLENDCAPS_DESTCOLOR |
3836 WINED3DPBLENDCAPS_INVDESTALPHA |
3837 WINED3DPBLENDCAPS_INVDESTCOLOR |
3838 WINED3DPBLENDCAPS_INVSRCALPHA |
3839 WINED3DPBLENDCAPS_INVSRCCOLOR |
3840 WINED3DPBLENDCAPS_ONE |
3841 WINED3DPBLENDCAPS_SRCALPHA |
3842 WINED3DPBLENDCAPS_SRCCOLOR |
3843 WINED3DPBLENDCAPS_ZERO;
3844 /* NOTE: WINED3DPBLENDCAPS_SRCALPHASAT is not supported as dest blend factor,
3845 * according to the glBlendFunc manpage
3846 *
3847 * WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA are
3848 * legacy settings for srcblend only
3849 */
3850
3851 if( GL_SUPPORT(EXT_BLEND_COLOR)) {
3852 pCaps->SrcBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
3853 pCaps->DestBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
3854 }
3855
3856
3857 pCaps->AlphaCmpCaps = WINED3DPCMPCAPS_ALWAYS |
3858 WINED3DPCMPCAPS_EQUAL |
3859 WINED3DPCMPCAPS_GREATER |
3860 WINED3DPCMPCAPS_GREATEREQUAL |
3861 WINED3DPCMPCAPS_LESS |
3862 WINED3DPCMPCAPS_LESSEQUAL |
3863 WINED3DPCMPCAPS_NEVER |
3864 WINED3DPCMPCAPS_NOTEQUAL;
3865
3866 pCaps->ShadeCaps = WINED3DPSHADECAPS_SPECULARGOURAUDRGB |
3867 WINED3DPSHADECAPS_COLORGOURAUDRGB |
3868 WINED3DPSHADECAPS_ALPHAFLATBLEND |
3869 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND |
3870 WINED3DPSHADECAPS_COLORFLATRGB |
3871 WINED3DPSHADECAPS_FOGFLAT |
3872 WINED3DPSHADECAPS_FOGGOURAUD |
3873 WINED3DPSHADECAPS_SPECULARFLATRGB;
3874
3875 pCaps->TextureCaps = WINED3DPTEXTURECAPS_ALPHA |
3876 WINED3DPTEXTURECAPS_ALPHAPALETTE |
3877 WINED3DPTEXTURECAPS_TRANSPARENCY |
3878 WINED3DPTEXTURECAPS_BORDER |
3879 WINED3DPTEXTURECAPS_MIPMAP |
3880 WINED3DPTEXTURECAPS_PROJECTED |
3881 WINED3DPTEXTURECAPS_PERSPECTIVE;
3882
3883 if( !GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO)) {
3884 pCaps->TextureCaps |= WINED3DPTEXTURECAPS_POW2 |
3885 WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL;
3886 }
3887
3888 if( GL_SUPPORT(EXT_TEXTURE3D)) {
3889 pCaps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP |
3890 WINED3DPTEXTURECAPS_MIPVOLUMEMAP |
3891 WINED3DPTEXTURECAPS_VOLUMEMAP_POW2;
3892 }
3893
3894 if (GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
3895 pCaps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP |
3896 WINED3DPTEXTURECAPS_MIPCUBEMAP |
3897 WINED3DPTEXTURECAPS_CUBEMAP_POW2;
3898
3899 }
3900
3901 pCaps->TextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
3902 WINED3DPTFILTERCAPS_MAGFPOINT |
3903 WINED3DPTFILTERCAPS_MINFLINEAR |
3904 WINED3DPTFILTERCAPS_MINFPOINT |
3905 WINED3DPTFILTERCAPS_MIPFLINEAR |
3906 WINED3DPTFILTERCAPS_MIPFPOINT |
3907 WINED3DPTFILTERCAPS_LINEAR |
3908 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
3909 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
3910 WINED3DPTFILTERCAPS_MIPLINEAR |
3911 WINED3DPTFILTERCAPS_MIPNEAREST |
3912 WINED3DPTFILTERCAPS_NEAREST;
3913
3914 if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
3915 pCaps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
3916 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
3917 }
3918
3919 if (GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
3920 pCaps->CubeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
3921 WINED3DPTFILTERCAPS_MAGFPOINT |
3922 WINED3DPTFILTERCAPS_MINFLINEAR |
3923 WINED3DPTFILTERCAPS_MINFPOINT |
3924 WINED3DPTFILTERCAPS_MIPFLINEAR |
3925 WINED3DPTFILTERCAPS_MIPFPOINT |
3926 WINED3DPTFILTERCAPS_LINEAR |
3927 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
3928 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
3929 WINED3DPTFILTERCAPS_MIPLINEAR |
3930 WINED3DPTFILTERCAPS_MIPNEAREST |
3931 WINED3DPTFILTERCAPS_NEAREST;
3932
3933 if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
3934 pCaps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
3935 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
3936 }
3937 } else
3938 pCaps->CubeTextureFilterCaps = 0;
3939
3940 if (GL_SUPPORT(EXT_TEXTURE3D)) {
3941 pCaps->VolumeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
3942 WINED3DPTFILTERCAPS_MAGFPOINT |
3943 WINED3DPTFILTERCAPS_MINFLINEAR |
3944 WINED3DPTFILTERCAPS_MINFPOINT |
3945 WINED3DPTFILTERCAPS_MIPFLINEAR |
3946 WINED3DPTFILTERCAPS_MIPFPOINT |
3947 WINED3DPTFILTERCAPS_LINEAR |
3948 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
3949 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
3950 WINED3DPTFILTERCAPS_MIPLINEAR |
3951 WINED3DPTFILTERCAPS_MIPNEAREST |
3952 WINED3DPTFILTERCAPS_NEAREST;
3953 } else
3954 pCaps->VolumeTextureFilterCaps = 0;
3955
3956 pCaps->TextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
3957 WINED3DPTADDRESSCAPS_CLAMP |
3958 WINED3DPTADDRESSCAPS_WRAP;
3959
3960 if (GL_SUPPORT(ARB_TEXTURE_BORDER_CLAMP)) {
3961 pCaps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
3962 }
3963 if (GL_SUPPORT(ARB_TEXTURE_MIRRORED_REPEAT)) {
3964 pCaps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
3965 }
3966 if (GL_SUPPORT(ATI_TEXTURE_MIRROR_ONCE)) {
3967 pCaps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
3968 }
3969
3970 if (GL_SUPPORT(EXT_TEXTURE3D)) {
3971 pCaps->VolumeTextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
3972 WINED3DPTADDRESSCAPS_CLAMP |
3973 WINED3DPTADDRESSCAPS_WRAP;
3974 if (GL_SUPPORT(ARB_TEXTURE_BORDER_CLAMP)) {
3975 pCaps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
3976 }
3977 if (GL_SUPPORT(ARB_TEXTURE_MIRRORED_REPEAT)) {
3978 pCaps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
3979 }
3980 if (GL_SUPPORT(ATI_TEXTURE_MIRROR_ONCE)) {
3981 pCaps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
3982 }
3983 } else
3984 pCaps->VolumeTextureAddressCaps = 0;
3985
3986 pCaps->LineCaps = WINED3DLINECAPS_TEXTURE |
3987 WINED3DLINECAPS_ZTEST |
3988 WINED3DLINECAPS_BLEND |
3989 WINED3DLINECAPS_ALPHACMP |
3990 WINED3DLINECAPS_FOG;
3991 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
3992 * idea how generating the smoothing alpha values works; the result is different
3993 */
3994
3995 pCaps->MaxTextureWidth = GL_LIMITS(texture_size);
3996 pCaps->MaxTextureHeight = GL_LIMITS(texture_size);
3997
3998 if(GL_SUPPORT(EXT_TEXTURE3D))
3999 pCaps->MaxVolumeExtent = GL_LIMITS(texture3d_size);
4000 else
4001 pCaps->MaxVolumeExtent = 0;
4002
4003 pCaps->MaxTextureRepeat = 32768;
4004 pCaps->MaxTextureAspectRatio = GL_LIMITS(texture_size);
4005 pCaps->MaxVertexW = 1.0f;
4006
4007 pCaps->GuardBandLeft = 0.0f;
4008 pCaps->GuardBandTop = 0.0f;
4009 pCaps->GuardBandRight = 0.0f;
4010 pCaps->GuardBandBottom = 0.0f;
4011
4012 pCaps->ExtentsAdjust = 0.0f;
4013
4014 pCaps->StencilCaps = WINED3DSTENCILCAPS_DECRSAT |
4015 WINED3DSTENCILCAPS_INCRSAT |
4016 WINED3DSTENCILCAPS_INVERT |
4017 WINED3DSTENCILCAPS_KEEP |
4018 WINED3DSTENCILCAPS_REPLACE |
4019 WINED3DSTENCILCAPS_ZERO;
4020 if (GL_SUPPORT(EXT_STENCIL_WRAP)) {
4021 pCaps->StencilCaps |= WINED3DSTENCILCAPS_DECR |
4022 WINED3DSTENCILCAPS_INCR;
4023 }
4024 if (GL_SUPPORT(EXT_STENCIL_TWO_SIDE) || GL_SUPPORT(ATI_SEPARATE_STENCIL)) {
4025 pCaps->StencilCaps |= WINED3DSTENCILCAPS_TWOSIDED;
4026 }
4027
4028 pCaps->FVFCaps = WINED3DFVFCAPS_PSIZE | 0x0008; /* 8 texture coords */
4029
4030 pCaps->MaxUserClipPlanes = GL_LIMITS(clipplanes);
4031 pCaps->MaxActiveLights = GL_LIMITS(lights);
4032
4033 pCaps->MaxVertexBlendMatrices = GL_LIMITS(blends);
4034 pCaps->MaxVertexBlendMatrixIndex = 0;
4035
4036 pCaps->MaxAnisotropy = GL_LIMITS(anisotropy);
4037 pCaps->MaxPointSize = GL_LIMITS(pointsize);
4038
4039
4040 /* FIXME: Add D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */
4041 pCaps->VertexProcessingCaps = WINED3DVTXPCAPS_DIRECTIONALLIGHTS |
4042 WINED3DVTXPCAPS_MATERIALSOURCE7 |
4043 WINED3DVTXPCAPS_POSITIONALLIGHTS |
4044 WINED3DVTXPCAPS_LOCALVIEWER |
4045 WINED3DVTXPCAPS_VERTEXFOG |
4046 WINED3DVTXPCAPS_TEXGEN;
4047
4048 pCaps->MaxPrimitiveCount = 0xFFFFF; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
4049 pCaps->MaxVertexIndex = 0xFFFFF;
4050 pCaps->MaxStreams = MAX_STREAMS;
4051 pCaps->MaxStreamStride = 1024;
4052
4053 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
4054 pCaps->DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET |
4055 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
4056 pCaps->MaxNpatchTessellationLevel = 0;
4057 pCaps->MasterAdapterOrdinal = 0;
4058 pCaps->AdapterOrdinalInGroup = 0;
4059 pCaps->NumberOfAdaptersInGroup = 1;
4060
4061 pCaps->NumSimultaneousRTs = GL_LIMITS(buffers);
4062
4063 pCaps->StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT |
4064 WINED3DPTFILTERCAPS_MAGFPOINT |
4065 WINED3DPTFILTERCAPS_MINFLINEAR |
4066 WINED3DPTFILTERCAPS_MAGFLINEAR;
4067 pCaps->VertexTextureFilterCaps = 0;
4068
4069 memset(&shader_caps, 0, sizeof(shader_caps));
4070 shader_backend = select_shader_backend(adapter, DeviceType);
4071 shader_backend->shader_get_caps(DeviceType, &adapter->gl_info, &shader_caps);
4072
4073 memset(&fragment_caps, 0, sizeof(fragment_caps));
4074 frag_pipeline = select_fragment_implementation(adapter, DeviceType);
4075 frag_pipeline->get_caps(DeviceType, &adapter->gl_info, &fragment_caps);
4076
4077 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
4078 pCaps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps;
4079
4080 /* This takes care for disabling vertex shader or pixel shader caps while leaving the other one enabled.
4081 * Ignore shader model capabilities if disabled in config
4082 */
4083 if(vs_selected_mode == SHADER_NONE) {
4084 TRACE_(d3d_caps)("Vertex shader disabled in config, reporting version 0.0\n");
4085 pCaps->VertexShaderVersion = WINED3DVS_VERSION(0,0);
4086 pCaps->MaxVertexShaderConst = 0;
4087 } else {
4088 pCaps->VertexShaderVersion = shader_caps.VertexShaderVersion;
4089 pCaps->MaxVertexShaderConst = shader_caps.MaxVertexShaderConst;
4090 }
4091
4092 if(ps_selected_mode == SHADER_NONE) {
4093 TRACE_(d3d_caps)("Pixel shader disabled in config, reporting version 0.0\n");
4094 pCaps->PixelShaderVersion = WINED3DPS_VERSION(0,0);
4095 pCaps->PixelShader1xMaxValue = 0.0f;
4096 } else {
4097 pCaps->PixelShaderVersion = shader_caps.PixelShaderVersion;
4098 pCaps->PixelShader1xMaxValue = shader_caps.PixelShader1xMaxValue;
4099 }
4100
4101 pCaps->TextureOpCaps = fragment_caps.TextureOpCaps;
4102 pCaps->MaxTextureBlendStages = fragment_caps.MaxTextureBlendStages;
4103 pCaps->MaxSimultaneousTextures = fragment_caps.MaxSimultaneousTextures;
4104
4105 pCaps->VS20Caps = shader_caps.VS20Caps;
4106 pCaps->MaxVShaderInstructionsExecuted = shader_caps.MaxVShaderInstructionsExecuted;
4107 pCaps->MaxVertexShader30InstructionSlots= shader_caps.MaxVertexShader30InstructionSlots;
4108 pCaps->PS20Caps = shader_caps.PS20Caps;
4109 pCaps->MaxPShaderInstructionsExecuted = shader_caps.MaxPShaderInstructionsExecuted;
4110 pCaps->MaxPixelShader30InstructionSlots = shader_caps.MaxPixelShader30InstructionSlots;
4111
4112 /* The following caps are shader specific, but they are things we cannot detect, or which
4113 * are the same among all shader models. So to avoid code duplication set the shader version
4114 * specific, but otherwise constant caps here
4115 */
4116 if(pCaps->VertexShaderVersion == WINED3DVS_VERSION(3,0)) {
4117 /* Where possible set the caps based on OpenGL extensions and if they aren't set (in case of software rendering)
4118 use the VS 3.0 from MSDN or else if there's OpenGL spec use a hardcoded value minimum VS3.0 value. */
4119 pCaps->VS20Caps.Caps = WINED3DVS20CAPS_PREDICATION;
4120 pCaps->VS20Caps.DynamicFlowControlDepth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH; /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4121 pCaps->VS20Caps.NumTemps = max(32, adapter->gl_info.vs_arb_max_temps);
4122 pCaps->VS20Caps.StaticFlowControlDepth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH ; /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
4123
4124 pCaps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
4125 pCaps->MaxVertexShader30InstructionSlots = max(512, adapter->gl_info.vs_arb_max_instructions);
4126 } else if(pCaps->VertexShaderVersion == WINED3DVS_VERSION(2,0)) {
4127 pCaps->VS20Caps.Caps = 0;
4128 pCaps->VS20Caps.DynamicFlowControlDepth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
4129 pCaps->VS20Caps.NumTemps = max(12, adapter->gl_info.vs_arb_max_temps);
4130 pCaps->VS20Caps.StaticFlowControlDepth = 1;
4131
4132 pCaps->MaxVShaderInstructionsExecuted = 65535;
4133 pCaps->MaxVertexShader30InstructionSlots = 0;
4134 } else { /* VS 1.x */
4135 pCaps->VS20Caps.Caps = 0;
4136 pCaps->VS20Caps.DynamicFlowControlDepth = 0;
4137 pCaps->VS20Caps.NumTemps = 0;
4138 pCaps->VS20Caps.StaticFlowControlDepth = 0;
4139
4140 pCaps->MaxVShaderInstructionsExecuted = 0;
4141 pCaps->MaxVertexShader30InstructionSlots = 0;
4142 }
4143
4144 if(pCaps->PixelShaderVersion == WINED3DPS_VERSION(3,0)) {
4145 /* Where possible set the caps based on OpenGL extensions and if they aren't set (in case of software rendering)
4146 use the PS 3.0 from MSDN or else if there's OpenGL spec use a hardcoded value minimum PS 3.0 value. */
4147
4148 /* Caps is more or less undocumented on MSDN but it appears to be used for PS20Caps based on results from R9600/FX5900/Geforce6800 cards from Windows */
4149 pCaps->PS20Caps.Caps = WINED3DPS20CAPS_ARBITRARYSWIZZLE |
4150 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS |
4151 WINED3DPS20CAPS_PREDICATION |
4152 WINED3DPS20CAPS_NODEPENDENTREADLIMIT |
4153 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT;
4154 pCaps->PS20Caps.DynamicFlowControlDepth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH; /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
4155 pCaps->PS20Caps.NumTemps = max(32, adapter->gl_info.ps_arb_max_temps);
4156 pCaps->PS20Caps.StaticFlowControlDepth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH; /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
4157 pCaps->PS20Caps.NumInstructionSlots = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS; /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
4158
4159 pCaps->MaxPShaderInstructionsExecuted = 65535;
4160 pCaps->MaxPixelShader30InstructionSlots = max(WINED3DMIN30SHADERINSTRUCTIONS, adapter->gl_info.ps_arb_max_instructions);
4161 } else if(pCaps->PixelShaderVersion == WINED3DPS_VERSION(2,0)) {
4162 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
4163 pCaps->PS20Caps.Caps = 0;
4164 pCaps->PS20Caps.DynamicFlowControlDepth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
4165 pCaps->PS20Caps.NumTemps = max(12, adapter->gl_info.ps_arb_max_temps);
4166 pCaps->PS20Caps.StaticFlowControlDepth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minimum: 1 */
4167 pCaps->PS20Caps.NumInstructionSlots = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS; /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
4168
4169 pCaps->MaxPShaderInstructionsExecuted = 512; /* Minimum value, a GeforceFX uses 1024 */
4170 pCaps->MaxPixelShader30InstructionSlots = 0;
4171 } else { /* PS 1.x */
4172 pCaps->PS20Caps.Caps = 0;
4173 pCaps->PS20Caps.DynamicFlowControlDepth = 0;
4174 pCaps->PS20Caps.NumTemps = 0;
4175 pCaps->PS20Caps.StaticFlowControlDepth = 0;
4176 pCaps->PS20Caps.NumInstructionSlots = 0;
4177
4178 pCaps->MaxPShaderInstructionsExecuted = 0;
4179 pCaps->MaxPixelShader30InstructionSlots = 0;
4180 }
4181
4182 if(pCaps->VertexShaderVersion >= WINED3DVS_VERSION(2,0)) {
4183 /* OpenGL supports all the formats below, perhaps not always
4184 * without conversion, but it supports them.
4185 * Further GLSL doesn't seem to have an official unsigned type so
4186 * don't advertise it yet as I'm not sure how we handle it.
4187 * We might need to add some clamping in the shader engine to
4188 * support it.
4189 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
4190 pCaps->DeclTypes = WINED3DDTCAPS_UBYTE4 |
4191 WINED3DDTCAPS_UBYTE4N |
4192 WINED3DDTCAPS_SHORT2N |
4193 WINED3DDTCAPS_SHORT4N;
4194 if (GL_SUPPORT(ARB_HALF_FLOAT_VERTEX)) {
4195 pCaps->DeclTypes |= WINED3DDTCAPS_FLOAT16_2 |
4196 WINED3DDTCAPS_FLOAT16_4;
4197 }
4198 } else
4199 pCaps->DeclTypes = 0;
4200
4201 /* Set DirectDraw helper Caps */
4202 ckey_caps = WINEDDCKEYCAPS_DESTBLT |
4203 WINEDDCKEYCAPS_SRCBLT;
4204 fx_caps = WINEDDFXCAPS_BLTALPHA |
4205 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT |
4206 WINEDDFXCAPS_BLTMIRRORUPDOWN |
4207 WINEDDFXCAPS_BLTROTATION90 |
4208 WINEDDFXCAPS_BLTSHRINKX |
4209 WINEDDFXCAPS_BLTSHRINKXN |
4210 WINEDDFXCAPS_BLTSHRINKY |
4211 WINEDDFXCAPS_BLTSHRINKXN |
4212 WINEDDFXCAPS_BLTSTRETCHX |
4213 WINEDDFXCAPS_BLTSTRETCHXN |
4214 WINEDDFXCAPS_BLTSTRETCHY |
4215 WINEDDFXCAPS_BLTSTRETCHYN;
4216 blit_caps = WINEDDCAPS_BLT |
4217 WINEDDCAPS_BLTCOLORFILL |
4218 WINEDDCAPS_BLTDEPTHFILL |
4219 WINEDDCAPS_BLTSTRETCH |
4220 WINEDDCAPS_CANBLTSYSMEM |
4221 WINEDDCAPS_CANCLIP |
4222 WINEDDCAPS_CANCLIPSTRETCHED |
4223 WINEDDCAPS_COLORKEY |
4224 WINEDDCAPS_COLORKEYHWASSIST |
4225 WINEDDCAPS_ALIGNBOUNDARYSRC;
4226
4227 /* Fill the ddraw caps structure */
4228 pCaps->DirectDrawCaps.Caps = WINEDDCAPS_GDI |
4229 WINEDDCAPS_PALETTE |
4230 blit_caps;
4231 pCaps->DirectDrawCaps.Caps2 = WINEDDCAPS2_CERTIFIED |
4232 WINEDDCAPS2_NOPAGELOCKREQUIRED |
4233 WINEDDCAPS2_PRIMARYGAMMA |
4234 WINEDDCAPS2_WIDESURFACES |
4235 WINEDDCAPS2_CANRENDERWINDOWED;
4236 pCaps->DirectDrawCaps.SVBCaps = blit_caps;
4237 pCaps->DirectDrawCaps.SVBCKeyCaps = ckey_caps;
4238 pCaps->DirectDrawCaps.SVBFXCaps = fx_caps;
4239 pCaps->DirectDrawCaps.VSBCaps = blit_caps;
4240 pCaps->DirectDrawCaps.VSBCKeyCaps = ckey_caps;
4241 pCaps->DirectDrawCaps.VSBFXCaps = fx_caps;
4242 pCaps->DirectDrawCaps.SSBCaps = blit_caps;
4243 pCaps->DirectDrawCaps.SSBCKeyCaps = ckey_caps;
4244 pCaps->DirectDrawCaps.SSBFXCaps = fx_caps;
4245
4246 pCaps->DirectDrawCaps.ddsCaps = WINEDDSCAPS_ALPHA |
4247 WINEDDSCAPS_BACKBUFFER |
4248 WINEDDSCAPS_FLIP |
4249 WINEDDSCAPS_FRONTBUFFER |
4250 WINEDDSCAPS_OFFSCREENPLAIN |
4251 WINEDDSCAPS_PALETTE |
4252 WINEDDSCAPS_PRIMARYSURFACE |
4253 WINEDDSCAPS_SYSTEMMEMORY |
4254 WINEDDSCAPS_VIDEOMEMORY |
4255 WINEDDSCAPS_VISIBLE;
4256 pCaps->DirectDrawCaps.StrideAlign = DDRAW_PITCH_ALIGNMENT;
4257
4258 /* Set D3D caps if OpenGL is available. */
4259 if (adapter->opengl)
4260 {
4261 pCaps->DirectDrawCaps.ddsCaps |=WINEDDSCAPS_3DDEVICE |
4262 WINEDDSCAPS_MIPMAP |
4263 WINEDDSCAPS_TEXTURE |
4264 WINEDDSCAPS_ZBUFFER;
4265 pCaps->DirectDrawCaps.Caps |= WINEDDCAPS_3D;
4266 }
4267
4268 return WINED3D_OK;
4269}
4270
4271/* Note due to structure differences between dx8 and dx9 D3DPRESENT_PARAMETERS,
4272 and fields being inserted in the middle, a new structure is used in place */
4273static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
4274 WINED3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviourFlags, IUnknown *parent,
4275 IWineD3DDeviceParent *device_parent, IWineD3DDevice **ppReturnedDeviceInterface)
4276{
4277 IWineD3DDeviceImpl *object = NULL;
4278 IWineD3DImpl *This = (IWineD3DImpl *)iface;
4279 struct WineD3DAdapter *adapter = &This->adapters[Adapter];
4280 WINED3DDISPLAYMODE mode;
4281 const struct fragment_pipeline *frag_pipeline = NULL;
4282 int i;
4283 struct fragment_caps ffp_caps;
4284 struct shader_caps shader_caps;
4285 HRESULT hr;
4286
4287 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
4288 * number and create a device without a 3D adapter for 2D only operation.
4289 */
4290 if (IWineD3D_GetAdapterCount(iface) && Adapter >= IWineD3D_GetAdapterCount(iface)) {
4291 return WINED3DERR_INVALIDCALL;
4292 }
4293
4294 /* Create a WineD3DDevice object */
4295 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DDeviceImpl));
4296 *ppReturnedDeviceInterface = (IWineD3DDevice *)object;
4297 TRACE("Created WineD3DDevice object @ %p\n", object);
4298 if (NULL == object) {
4299 return WINED3DERR_OUTOFVIDEOMEMORY;
4300 }
4301
4302 /* Set up initial COM information */
4303 object->lpVtbl = &IWineD3DDevice_Vtbl;
4304 object->ref = 1;
4305 object->wineD3D = iface;
4306 object->adapter = This->adapter_count ? adapter : NULL;
4307 IWineD3D_AddRef(object->wineD3D);
4308 object->parent = parent;
4309 object->device_parent = device_parent;
4310 list_init(&object->resources);
4311 list_init(&object->shaders);
4312
4313 if(This->dxVersion == 7) {
4314 object->surface_alignment = DDRAW_PITCH_ALIGNMENT;
4315 } else {
4316 object->surface_alignment = D3D8_PITCH_ALIGNMENT;
4317 }
4318 object->posFixup[0] = 1.0f; /* This is needed to get the x coord unmodified through a MAD. */
4319
4320 /* Set the state up as invalid until the device is fully created */
4321 object->state = WINED3DERR_DRIVERINTERNALERROR;
4322
4323 TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %x, RetDevInt: %p)\n", This, Adapter, DeviceType,
4324 hFocusWindow, BehaviourFlags, ppReturnedDeviceInterface);
4325
4326 /* Save the creation parameters */
4327 object->createParms.AdapterOrdinal = Adapter;
4328 object->createParms.DeviceType = DeviceType;
4329 object->createParms.hFocusWindow = hFocusWindow;
4330 object->createParms.BehaviorFlags = BehaviourFlags;
4331
4332 /* Initialize other useful values */
4333 object->adapterNo = Adapter;
4334 object->devType = DeviceType;
4335
4336 select_shader_mode(&adapter->gl_info, &object->ps_selected_mode, &object->vs_selected_mode);
4337 object->shader_backend = select_shader_backend(adapter, DeviceType);
4338
4339 memset(&shader_caps, 0, sizeof(shader_caps));
4340 object->shader_backend->shader_get_caps(DeviceType, &adapter->gl_info, &shader_caps);
4341 object->d3d_vshader_constantF = shader_caps.MaxVertexShaderConst;
4342 object->d3d_pshader_constantF = shader_caps.MaxPixelShaderConst;
4343 object->vs_clipping = shader_caps.VSClipping;
4344
4345 memset(&ffp_caps, 0, sizeof(ffp_caps));
4346 frag_pipeline = select_fragment_implementation(adapter, DeviceType);
4347 object->frag_pipe = frag_pipeline;
4348 frag_pipeline->get_caps(DeviceType, &adapter->gl_info, &ffp_caps);
4349 object->max_ffp_textures = ffp_caps.MaxSimultaneousTextures;
4350 object->max_ffp_texture_stages = ffp_caps.MaxTextureBlendStages;
4351 hr = compile_state_table(object->StateTable, object->multistate_funcs, &adapter->gl_info,
4352 ffp_vertexstate_template, frag_pipeline, misc_state_template);
4353
4354 if (FAILED(hr)) {
4355 IWineD3D_Release(object->wineD3D);
4356 HeapFree(GetProcessHeap(), 0, object);
4357
4358 return hr;
4359 }
4360
4361 object->blitter = select_blit_implementation(adapter, DeviceType);
4362
4363 /* set the state of the device to valid */
4364 object->state = WINED3D_OK;
4365
4366 /* Get the initial screen setup for ddraw */
4367 IWineD3DImpl_GetAdapterDisplayMode(iface, Adapter, &mode);
4368
4369 object->ddraw_width = mode.Width;
4370 object->ddraw_height = mode.Height;
4371 object->ddraw_format = mode.Format;
4372
4373 for(i = 0; i < PATCHMAP_SIZE; i++) {
4374 list_init(&object->patches[i]);
4375 }
4376
4377 IWineD3DDeviceParent_WineD3DDeviceCreated(device_parent, *ppReturnedDeviceInterface);
4378
4379 return WINED3D_OK;
4380}
4381
4382static HRESULT WINAPI IWineD3DImpl_GetParent(IWineD3D *iface, IUnknown **pParent) {
4383 IWineD3DImpl *This = (IWineD3DImpl *)iface;
4384 IUnknown_AddRef(This->parent);
4385 *pParent = This->parent;
4386 return WINED3D_OK;
4387}
4388
4389ULONG WINAPI D3DCB_DefaultDestroyVolume(IWineD3DVolume *pVolume) {
4390 IUnknown* volumeParent;
4391 TRACE("(%p) call back\n", pVolume);
4392
4393 /* Now, release the parent, which will take care of cleaning up the volume for us */
4394 IWineD3DVolume_GetParent(pVolume, &volumeParent);
4395 IUnknown_Release(volumeParent);
4396 return IUnknown_Release(volumeParent);
4397}
4398
4399static void WINE_GLAPI invalid_func(const void *data)
4400{
4401 ERR("Invalid vertex attribute function called\n");
4402 DebugBreak();
4403}
4404
4405static void WINE_GLAPI invalid_texcoord_func(GLenum unit, const void *data)
4406{
4407 ERR("Invalid texcoord function called\n");
4408 DebugBreak();
4409}
4410
4411/* Helper functions for providing vertex data to opengl. The arrays are initialized based on
4412 * the extension detection and are used in drawStridedSlow
4413 */
4414static void WINE_GLAPI position_d3dcolor(const void *data)
4415{
4416 DWORD pos = *((const DWORD *)data);
4417
4418 FIXME("Add a test for fixed function position from d3dcolor type\n");
4419 glVertex4s(D3DCOLOR_B_R(pos),
4420 D3DCOLOR_B_G(pos),
4421 D3DCOLOR_B_B(pos),
4422 D3DCOLOR_B_A(pos));
4423}
4424
4425static void WINE_GLAPI position_float4(const void *data)
4426{
4427 const GLfloat *pos = data;
4428
4429 if (pos[3] != 0.0f && pos[3] != 1.0f)
4430 {
4431 float w = 1.0f / pos[3];
4432
4433 glVertex4f(pos[0] * w, pos[1] * w, pos[2] * w, w);
4434 }
4435 else
4436 {
4437 glVertex3fv(pos);
4438 }
4439}
4440
4441static void WINE_GLAPI diffuse_d3dcolor(const void *data)
4442{
4443 DWORD diffuseColor = *((const DWORD *)data);
4444
4445 glColor4ub(D3DCOLOR_B_R(diffuseColor),
4446 D3DCOLOR_B_G(diffuseColor),
4447 D3DCOLOR_B_B(diffuseColor),
4448 D3DCOLOR_B_A(diffuseColor));
4449}
4450
4451static void WINE_GLAPI specular_d3dcolor(const void *data)
4452{
4453 DWORD specularColor = *((const DWORD *)data);
4454 GLbyte d[] = {D3DCOLOR_B_R(specularColor),
4455 D3DCOLOR_B_G(specularColor),
4456 D3DCOLOR_B_B(specularColor)};
4457
4458 specular_func_3ubv(d);
4459}
4460
4461static void WINE_GLAPI warn_no_specular_func(const void *data)
4462{
4463 WARN("GL_EXT_secondary_color not supported\n");
4464}
4465
4466static void fillGLAttribFuncs(const struct wined3d_gl_info *gl_info)
4467{
4468 position_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
4469 position_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
4470 position_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)glVertex3fv;
4471 position_funcs[WINED3D_FFP_EMIT_FLOAT4] = position_float4;
4472 position_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = position_d3dcolor;
4473 position_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
4474 position_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
4475 position_funcs[WINED3D_FFP_EMIT_SHORT4] = (glAttribFunc)glVertex2sv;
4476 position_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
4477 position_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
4478 position_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
4479 position_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
4480 position_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
4481 position_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
4482 position_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
4483 position_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
4484 position_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
4485
4486 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
4487 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
4488 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)glColor3fv;
4489 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glAttribFunc)glColor4fv;
4490 diffuse_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = diffuse_d3dcolor;
4491 diffuse_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
4492 diffuse_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
4493 diffuse_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
4494 diffuse_funcs[WINED3D_FFP_EMIT_UBYTE4N] = (glAttribFunc)glColor4ubv;
4495 diffuse_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
4496 diffuse_funcs[WINED3D_FFP_EMIT_SHORT4N] = (glAttribFunc)glColor4sv;
4497 diffuse_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
4498 diffuse_funcs[WINED3D_FFP_EMIT_USHORT4N] = (glAttribFunc)glColor4usv;
4499 diffuse_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
4500 diffuse_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
4501 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
4502 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
4503
4504 /* No 4 component entry points here */
4505 specular_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
4506 specular_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
4507 if(GL_SUPPORT(EXT_SECONDARY_COLOR)) {
4508 specular_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)GL_EXTCALL(glSecondaryColor3fvEXT);
4509 } else {
4510 specular_funcs[WINED3D_FFP_EMIT_FLOAT3] = warn_no_specular_func;
4511 }
4512 specular_funcs[WINED3D_FFP_EMIT_FLOAT4] = invalid_func;
4513 if(GL_SUPPORT(EXT_SECONDARY_COLOR)) {
4514 specular_func_3ubv = (glAttribFunc)GL_EXTCALL(glSecondaryColor3ubvEXT);
4515 specular_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = specular_d3dcolor;
4516 } else {
4517 specular_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = warn_no_specular_func;
4518 }
4519 specular_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
4520 specular_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
4521 specular_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
4522 specular_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
4523 specular_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
4524 specular_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
4525 specular_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
4526 specular_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
4527 specular_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
4528 specular_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
4529 specular_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
4530 specular_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
4531
4532 /* Only 3 component entry points here. Test how others behave. Float4 normals are used
4533 * by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
4534 */
4535 normal_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
4536 normal_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
4537 normal_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)glNormal3fv;
4538 normal_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glAttribFunc)glNormal3fv; /* Just ignore the 4th value */
4539 normal_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = invalid_func;
4540 normal_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
4541 normal_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
4542 normal_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
4543 normal_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
4544 normal_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
4545 normal_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
4546 normal_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
4547 normal_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
4548 normal_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
4549 normal_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
4550 normal_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
4551 normal_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
4552
4553 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT1] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord1fvARB);
4554 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2fvARB);
4555 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord3fvARB);
4556 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4fvARB);
4557 multi_texcoord_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = invalid_texcoord_func;
4558 multi_texcoord_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_texcoord_func;
4559 multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2svARB);
4560 multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4svARB);
4561 multi_texcoord_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_texcoord_func;
4562 multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_texcoord_func;
4563 multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_texcoord_func;
4564 multi_texcoord_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_texcoord_func;
4565 multi_texcoord_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_texcoord_func;
4566 multi_texcoord_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_texcoord_func;
4567 multi_texcoord_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_texcoord_func;
4568 if (GL_SUPPORT(NV_HALF_FLOAT))
4569 {
4570 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT */
4571 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2hvNV);
4572 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4hvNV);
4573 } else {
4574 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_texcoord_func;
4575 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_texcoord_func;
4576 }
4577}
4578
4579BOOL InitAdapters(IWineD3DImpl *This)
4580{
4581 static HMODULE mod_gl;
4582 BOOL ret;
4583 int ps_selected_mode, vs_selected_mode;
4584
4585 /* No need to hold any lock. The calling library makes sure only one thread calls
4586 * wined3d simultaneously
4587 */
4588
4589 TRACE("Initializing adapters\n");
4590
4591 if(!mod_gl) {
4592#ifdef USE_WIN32_OPENGL
4593#define USE_GL_FUNC(pfn) pfn = (void*)GetProcAddress(mod_gl, #pfn);
4594 mod_gl = LoadLibraryA("opengl32.dll");
4595 if(!mod_gl) {
4596 ERR("Can't load opengl32.dll!\n");
4597 goto nogl_adapter;
4598 }
4599#else
4600#define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);
4601 /* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 (glXGetProcAddress wrapper) instead of opengl32's */
4602 mod_gl = GetModuleHandleA("gdi32.dll");
4603#endif
4604 }
4605
4606/* Load WGL core functions from opengl32.dll */
4607#define USE_WGL_FUNC(pfn) p##pfn = (void*)GetProcAddress(mod_gl, #pfn);
4608 WGL_FUNCS_GEN;
4609#undef USE_WGL_FUNC
4610
4611 if(!pwglGetProcAddress) {
4612 ERR("Unable to load wglGetProcAddress!\n");
4613 goto nogl_adapter;
4614 }
4615
4616/* Dynamically load all GL core functions */
4617 GL_FUNCS_GEN;
4618#undef USE_GL_FUNC
4619
4620 /* Load glFinish and glFlush from opengl32.dll even if we're not using WIN32 opengl
4621 * otherwise because we have to use winex11.drv's override
4622 */
4623#ifdef USE_WIN32_OPENGL
4624 wglFinish = (void*)GetProcAddress(mod_gl, "glFinish");
4625 wglFlush = (void*)GetProcAddress(mod_gl, "glFlush");
4626#else
4627 wglFinish = (void*)pwglGetProcAddress("wglFinish");
4628 wglFlush = (void*)pwglGetProcAddress("wglFlush");
4629#endif
4630
4631 glEnableWINE = glEnable;
4632 glDisableWINE = glDisable;
4633
4634 /* For now only one default adapter */
4635 {
4636 struct WineD3DAdapter *adapter = &This->adapters[0];
4637 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
4638 struct wined3d_fake_gl_ctx fake_gl_ctx = {0};
4639 int iPixelFormat;
4640 int res;
4641 int i;
4642 WineD3D_PixelFormat *cfgs;
4643 DISPLAY_DEVICEW DisplayDevice;
4644 HDC hdc;
4645
4646 TRACE("Initializing default adapter\n");
4647 adapter->num = 0;
4648 adapter->monitorPoint.x = -1;
4649 adapter->monitorPoint.y = -1;
4650
4651 if (!WineD3D_CreateFakeGLContext(&fake_gl_ctx))
4652 {
4653 ERR("Failed to get a gl context for default adapter\n");
4654 goto nogl_adapter;
4655 }
4656
4657 ret = IWineD3DImpl_FillGLCaps(&adapter->gl_info);
4658 if(!ret) {
4659 ERR("Failed to initialize gl caps for default adapter\n");
4660 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
4661 goto nogl_adapter;
4662 }
4663 ret = initPixelFormats(&adapter->gl_info);
4664 if(!ret) {
4665 ERR("Failed to init gl formats\n");
4666 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
4667 goto nogl_adapter;
4668 }
4669
4670 hdc = fake_gl_ctx.dc;
4671
4672 adapter->driver = "Display";
4673 adapter->description = "Direct3D HAL";
4674
4675 /* Use the VideoRamSize registry setting when set */
4676 if(wined3d_settings.emulated_textureram)
4677 adapter->TextureRam = wined3d_settings.emulated_textureram;
4678 else
4679 adapter->TextureRam = adapter->gl_info.vidmem;
4680 adapter->UsedTextureRam = 0;
4681 TRACE("Emulating %dMB of texture ram\n", adapter->TextureRam/(1024*1024));
4682
4683 /* Initialize the Adapter's DeviceName which is required for ChangeDisplaySettings and friends */
4684 DisplayDevice.cb = sizeof(DisplayDevice);
4685 EnumDisplayDevicesW(NULL, 0 /* Adapter 0 = iDevNum 0 */, &DisplayDevice, 0);
4686 TRACE("DeviceName: %s\n", debugstr_w(DisplayDevice.DeviceName));
4687 strcpyW(adapter->DeviceName, DisplayDevice.DeviceName);
4688
4689 if(GL_SUPPORT(WGL_ARB_PIXEL_FORMAT))
4690 {
4691 int attribute;
4692 int attribs[10];
4693 int values[10];
4694 int nAttribs = 0;
4695
4696 attribute = WGL_NUMBER_PIXEL_FORMATS_ARB;
4697 GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, &attribute, &adapter->nCfgs));
4698
4699 adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, adapter->nCfgs *sizeof(WineD3D_PixelFormat));
4700 cfgs = adapter->cfgs;
4701 attribs[nAttribs++] = WGL_RED_BITS_ARB;
4702 attribs[nAttribs++] = WGL_GREEN_BITS_ARB;
4703 attribs[nAttribs++] = WGL_BLUE_BITS_ARB;
4704 attribs[nAttribs++] = WGL_ALPHA_BITS_ARB;
4705 attribs[nAttribs++] = WGL_DEPTH_BITS_ARB;
4706 attribs[nAttribs++] = WGL_STENCIL_BITS_ARB;
4707 attribs[nAttribs++] = WGL_DRAW_TO_WINDOW_ARB;
4708 attribs[nAttribs++] = WGL_PIXEL_TYPE_ARB;
4709 attribs[nAttribs++] = WGL_DOUBLE_BUFFER_ARB;
4710 attribs[nAttribs++] = WGL_AUX_BUFFERS_ARB;
4711
4712 for (iPixelFormat=1; iPixelFormat <= adapter->nCfgs; ++iPixelFormat)
4713 {
4714 res = GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0, nAttribs, attribs, values));
4715
4716 if(!res)
4717 continue;
4718
4719 /* Cache the pixel format */
4720 cfgs->iPixelFormat = iPixelFormat;
4721 cfgs->redSize = values[0];
4722 cfgs->greenSize = values[1];
4723 cfgs->blueSize = values[2];
4724 cfgs->alphaSize = values[3];
4725 cfgs->depthSize = values[4];
4726 cfgs->stencilSize = values[5];
4727 cfgs->windowDrawable = values[6];
4728 cfgs->iPixelType = values[7];
4729 cfgs->doubleBuffer = values[8];
4730 cfgs->auxBuffers = values[9];
4731
4732 cfgs->pbufferDrawable = FALSE;
4733 /* Check for pbuffer support when it is around as wglGetPixelFormatAttribiv fails for unknown attributes. */
4734 if(GL_SUPPORT(WGL_ARB_PBUFFER)) {
4735 int attrib = WGL_DRAW_TO_PBUFFER_ARB;
4736 int value;
4737 if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0, 1, &attrib, &value)))
4738 cfgs->pbufferDrawable = value;
4739 }
4740
4741 cfgs->numSamples = 0;
4742 /* Check multisample support */
4743 if(GL_SUPPORT(ARB_MULTISAMPLE)) {
4744 int attrib[2] = {WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB};
4745 int value[2];
4746 if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0, 2, attrib, value))) {
4747 /* value[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether multisampling is supported.
4748 * value[1] = number of multi sample buffers*/
4749 if(value[0])
4750 cfgs->numSamples = value[1];
4751 }
4752 }
4753
4754 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, depth=%d, stencil=%d, windowDrawable=%d, pbufferDrawable=%d\n", cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer, cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize, cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable, cfgs->pbufferDrawable);
4755 cfgs++;
4756 }
4757 }
4758 else
4759 {
4760 int nCfgs = DescribePixelFormat(hdc, 0, 0, 0);
4761 adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nCfgs*sizeof(WineD3D_PixelFormat));
4762 adapter->nCfgs = 0; /* We won't accept all formats e.g. software accelerated ones will be skipped */
4763
4764 cfgs = adapter->cfgs;
4765 for(iPixelFormat=1; iPixelFormat<=nCfgs; iPixelFormat++)
4766 {
4767 PIXELFORMATDESCRIPTOR ppfd;
4768
4769 res = DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &ppfd);
4770 if(!res)
4771 continue;
4772
4773 /* We only want HW acceleration using an OpenGL ICD driver.
4774 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering
4775 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD driver (e.g. 3dfx minigl)
4776 */
4777 if(ppfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED))
4778 {
4779 TRACE("Skipping iPixelFormat=%d because it isn't ICD accelerated\n", iPixelFormat);
4780 continue;
4781 }
4782
4783 cfgs->iPixelFormat = iPixelFormat;
4784 cfgs->redSize = ppfd.cRedBits;
4785 cfgs->greenSize = ppfd.cGreenBits;
4786 cfgs->blueSize = ppfd.cBlueBits;
4787 cfgs->alphaSize = ppfd.cAlphaBits;
4788 cfgs->depthSize = ppfd.cDepthBits;
4789 cfgs->stencilSize = ppfd.cStencilBits;
4790 cfgs->pbufferDrawable = 0;
4791 cfgs->windowDrawable = (ppfd.dwFlags & PFD_DRAW_TO_WINDOW) ? 1 : 0;
4792 cfgs->iPixelType = (ppfd.iPixelType == PFD_TYPE_RGBA) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB;
4793 cfgs->doubleBuffer = (ppfd.dwFlags & PFD_DOUBLEBUFFER) ? 1 : 0;
4794 cfgs->auxBuffers = ppfd.cAuxBuffers;
4795 cfgs->numSamples = 0;
4796
4797 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, depth=%d, stencil=%d, windowDrawable=%d, pbufferDrawable=%d\n", cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer, cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize, cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable, cfgs->pbufferDrawable);
4798 cfgs++;
4799 adapter->nCfgs++;
4800 }
4801
4802 /* Yikes we haven't found any suitable formats. This should only happen in case of GDI software rendering which we can't use anyway as its 3D functionality is very, very limited */
4803 if(!adapter->nCfgs)
4804 {
4805 ERR("Disabling Direct3D because no hardware accelerated pixel formats have been found!\n");
4806
4807 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
4808 HeapFree(GetProcessHeap(), 0, adapter->cfgs);
4809 goto nogl_adapter;
4810 }
4811 }
4812
4813 /* D16, D24X8 and D24S8 are common depth / depth+stencil formats. All drivers support them though this doesn't
4814 * mean that the format is offered in hardware. For instance Geforce8 cards don't have offer D16 in hardware
4815 * but just fake it using D24(X8?) which is fine. D3D also allows that.
4816 * Some display drivers (i915 on Linux) only report mixed depth+stencil formats like D24S8. MSDN clearly mentions
4817 * that only on lockable formats (e.g. D16_locked) the bit order is guaranteed and that on other formats the
4818 * driver is allowed to consume more bits EXCEPT for stencil bits.
4819 *
4820 * Mark an adapter with this broken stencil behavior.
4821 */
4822 adapter->brokenStencil = TRUE;
4823 for (i = 0, cfgs = adapter->cfgs; i < adapter->nCfgs; ++i)
4824 {
4825 /* Nearly all drivers offer depth formats without stencil, only on i915 this if-statement won't be entered. */
4826 if(cfgs[i].depthSize && !cfgs[i].stencilSize) {
4827 adapter->brokenStencil = FALSE;
4828 break;
4829 }
4830 }
4831
4832 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
4833
4834 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
4835 select_shader_max_constants(ps_selected_mode, vs_selected_mode, &adapter->gl_info);
4836 fillGLAttribFuncs(&adapter->gl_info);
4837 adapter->opengl = TRUE;
4838 }
4839 This->adapter_count = 1;
4840 TRACE("%u adapters successfully initialized\n", This->adapter_count);
4841
4842 return TRUE;
4843
4844nogl_adapter:
4845 /* Initialize an adapter for ddraw-only memory counting */
4846 memset(This->adapters, 0, sizeof(This->adapters));
4847 This->adapters[0].num = 0;
4848 This->adapters[0].opengl = FALSE;
4849 This->adapters[0].monitorPoint.x = -1;
4850 This->adapters[0].monitorPoint.y = -1;
4851
4852 This->adapters[0].driver = "Display";
4853 This->adapters[0].description = "WineD3D DirectDraw Emulation";
4854 if(wined3d_settings.emulated_textureram) {
4855 This->adapters[0].TextureRam = wined3d_settings.emulated_textureram;
4856 } else {
4857 This->adapters[0].TextureRam = 8 * 1024 * 1024; /* This is plenty for a DDraw-only card */
4858 }
4859
4860 initPixelFormatsNoGL(&This->adapters[0].gl_info);
4861
4862 This->adapter_count = 1;
4863 return FALSE;
4864}
4865
4866/**********************************************************
4867 * IWineD3D VTbl follows
4868 **********************************************************/
4869
4870const IWineD3DVtbl IWineD3D_Vtbl =
4871{
4872 /* IUnknown */
4873 IWineD3DImpl_QueryInterface,
4874 IWineD3DImpl_AddRef,
4875 IWineD3DImpl_Release,
4876 /* IWineD3D */
4877 IWineD3DImpl_GetParent,
4878 IWineD3DImpl_GetAdapterCount,
4879 IWineD3DImpl_RegisterSoftwareDevice,
4880 IWineD3DImpl_GetAdapterMonitor,
4881 IWineD3DImpl_GetAdapterModeCount,
4882 IWineD3DImpl_EnumAdapterModes,
4883 IWineD3DImpl_GetAdapterDisplayMode,
4884 IWineD3DImpl_GetAdapterIdentifier,
4885 IWineD3DImpl_CheckDeviceMultiSampleType,
4886 IWineD3DImpl_CheckDepthStencilMatch,
4887 IWineD3DImpl_CheckDeviceType,
4888 IWineD3DImpl_CheckDeviceFormat,
4889 IWineD3DImpl_CheckDeviceFormatConversion,
4890 IWineD3DImpl_GetDeviceCaps,
4891 IWineD3DImpl_CreateDevice
4892};
4893
4894static void STDMETHODCALLTYPE wined3d_null_wined3d_object_destroyed(void *parent) {}
4895
4896const struct wined3d_parent_ops wined3d_null_parent_ops =
4897{
4898 wined3d_null_wined3d_object_destroyed,
4899};
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette