2 * IWineD3D implementation
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2003-2004 Raphael Junqueira
6 * Copyright 2004 Christian Costa
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 /* Compile time diagnostics: */
25 /* Uncomment this to force only a single display mode to be exposed: */
26 /*#define DEBUG_SINGLE_MODE*/
30 #include "wined3d_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
33 WINE_DECLARE_DEBUG_CHANNEL(d3d_caps
);
35 /**********************************************************
36 * Utility functions follow
37 **********************************************************/
39 /* x11drv GDI escapes */
40 #define X11DRV_ESCAPE 6789
41 enum x11drv_escape_codes
43 X11DRV_GET_DISPLAY
, /* get X11 display for a DC */
44 X11DRV_GET_DRAWABLE
, /* get current drawable for a DC */
45 X11DRV_GET_FONT
, /* get current X font for a DC */
48 /* retrieve the X display to use on a given DC */
49 inline static Display
*get_display( HDC hdc
)
52 enum x11drv_escape_codes escape
= X11DRV_GET_DISPLAY
;
54 if (!ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
), (LPCSTR
)&escape
,
55 sizeof(display
), (LPSTR
)&display
)) display
= NULL
;
60 * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created
61 * ie there is no GL Context - Get a default rendering context to enable the
62 * function query some info from GL
64 static WineD3D_Context
* WineD3D_CreateFakeGLContext(void) {
65 static WineD3D_Context ctx
= { NULL
, NULL
, NULL
, 0, 0 };
66 WineD3D_Context
* ret
= NULL
;
68 if (glXGetCurrentContext() == NULL
) {
69 BOOL gotContext
= FALSE
;
76 XWindowAttributes win_attr
;
78 TRACE_(d3d_caps
)("Creating Fake GL Context\n");
80 ctx
.drawable
= (Drawable
) GetPropA(GetDesktopWindow(), "__wine_x11_whole_window");
83 device_context
= GetDC(0);
84 ctx
.display
= get_display(device_context
);
85 ReleaseDC(0, device_context
);
87 /* Get the X visual */
89 if (XGetWindowAttributes(ctx
.display
, ctx
.drawable
, &win_attr
)) {
90 visual
= win_attr
.visual
;
92 visual
= DefaultVisual(ctx
.display
, DefaultScreen(ctx
.display
));
94 template.visualid
= XVisualIDFromVisual(visual
);
95 ctx
.visInfo
= XGetVisualInfo(ctx
.display
, VisualIDMask
, &template, &num
);
96 if (ctx
.visInfo
== NULL
) {
98 WARN_(d3d_caps
)("Error creating visual info for capabilities initialization\n");
102 /* Create a GL context */
104 ctx
.glCtx
= glXCreateContext(ctx
.display
, ctx
.visInfo
, NULL
, GL_TRUE
);
106 if (ctx
.glCtx
== NULL
) {
108 WARN_(d3d_caps
)("Error creating default context for capabilities initialization\n");
113 /* Make it the current GL context */
114 if (!failed
&& glXMakeCurrent(ctx
.display
, ctx
.drawable
, ctx
.glCtx
) == False
) {
115 glXDestroyContext(ctx
.display
, ctx
.glCtx
);
117 WARN_(d3d_caps
)("Error setting default context as current for capabilities initialization\n");
121 /* It worked! Wow... */
131 if (ctx
.ref
> 0) ret
= &ctx
;
134 if (NULL
!= ret
) InterlockedIncrement(&ret
->ref
);
138 static void WineD3D_ReleaseFakeGLContext(WineD3D_Context
* ctx
) {
139 /* If we created a dummy context, throw it away */
141 if (0 == InterlockedDecrement(&ctx
->ref
)) {
142 glXMakeCurrent(ctx
->display
, None
, NULL
);
143 glXDestroyContext(ctx
->display
, ctx
->glCtx
);
151 static BOOL
IWineD3DImpl_FillGLCaps(WineD3D_GL_Info
*gl_info
, Display
* display
) {
152 const char *GL_Extensions
= NULL
;
153 const char *GLX_Extensions
= NULL
;
154 const char *gl_string
= NULL
;
155 const char *gl_string_cursor
= NULL
;
160 TRACE_(d3d_caps
)("(%p, %p)\n", gl_info
, display
);
162 /* Fill in the GL info retrievable depending on the display */
163 if (NULL
!= display
) {
164 test
= glXQueryVersion(display
, &major
, &minor
);
165 gl_info
->glx_version
= ((major
& 0x0000FFFF) << 16) | (minor
& 0x0000FFFF);
166 gl_string
= glXGetClientString(display
, GLX_VENDOR
);
168 gl_string
= glGetString(GL_VENDOR
);
171 /* Fill in the GL vendor */
172 if (strstr(gl_string
, "NVIDIA")) {
173 gl_info
->gl_vendor
= VENDOR_NVIDIA
;
174 } else if (strstr(gl_string
, "ATI")) {
175 gl_info
->gl_vendor
= VENDOR_ATI
;
177 gl_info
->gl_vendor
= VENDOR_WINE
;
180 TRACE_(d3d_caps
)("found GL_VENDOR (%s)->(0x%04x)\n", debugstr_a(gl_string
), gl_info
->gl_vendor
);
182 /* Parse the GL_VERSION field into major and minor information */
183 gl_string
= glGetString(GL_VERSION
);
184 switch (gl_info
->gl_vendor
) {
186 gl_string_cursor
= strstr(gl_string
, "NVIDIA");
187 gl_string_cursor
= strstr(gl_string_cursor
, " ");
188 while (*gl_string_cursor
&& ' ' == *gl_string_cursor
) ++gl_string_cursor
;
189 if (*gl_string_cursor
) {
193 while (*gl_string_cursor
<= '9' && *gl_string_cursor
>= '0') {
194 tmp
[cursor
++] = *gl_string_cursor
;
200 if (*gl_string_cursor
!= '.') WARN_(d3d_caps
)("malformed GL_VERSION (%s)\n", debugstr_a(gl_string
));
203 while (*gl_string_cursor
<= '9' && *gl_string_cursor
>= '0') {
204 tmp
[cursor
++] = *gl_string_cursor
;
214 gl_string_cursor
= strchr(gl_string
, '-');
215 if (gl_string_cursor
++) {
218 /* Check if version number is of the form x.y.z */
219 if (*gl_string_cursor
> '9' && *gl_string_cursor
< '0')
221 if (!error
&& *(gl_string_cursor
+2) > '9' && *(gl_string_cursor
+2) < '0')
223 if (!error
&& *(gl_string_cursor
+4) > '9' && *(gl_string_cursor
+4) < '0')
225 if (!error
&& *(gl_string_cursor
+1) != '.' && *(gl_string_cursor
+3) != '.')
228 /* Mark version number as malformed */
230 gl_string_cursor
= 0;
233 if (!gl_string_cursor
)
234 WARN_(d3d_caps
)("malformed GL_VERSION (%s)\n", debugstr_a(gl_string
));
236 major
= *gl_string_cursor
- '0';
237 minor
= (*(gl_string_cursor
+2) - '0') * 256 + (*(gl_string_cursor
+4) - '0');
245 gl_info
->gl_driver_version
= MAKEDWORD_VERSION(major
, minor
);
246 TRACE_(d3d_caps
)("found GL_VERSION (%s)->(0x%08lx)\n", debugstr_a(gl_string
), gl_info
->gl_driver_version
);
248 /* Fill in the renderer information */
249 gl_string
= glGetString(GL_RENDERER
);
250 strcpy(gl_info
->gl_renderer
, gl_string
);
252 switch (gl_info
->gl_vendor
) {
254 if (strstr(gl_info
->gl_renderer
, "GeForce4 Ti")) {
255 gl_info
->gl_card
= CARD_NVIDIA_GEFORCE4_TI4600
;
256 } else if (strstr(gl_info
->gl_renderer
, "GeForceFX")) {
257 gl_info
->gl_card
= CARD_NVIDIA_GEFORCEFX_5900ULTRA
;
259 gl_info
->gl_card
= CARD_NVIDIA_GEFORCE4_TI4600
;
264 if (strstr(gl_info
->gl_renderer
, "RADEON 9800 PRO")) {
265 gl_info
->gl_card
= CARD_ATI_RADEON_9800PRO
;
266 } else if (strstr(gl_info
->gl_renderer
, "RADEON 9700 PRO")) {
267 gl_info
->gl_card
= CARD_ATI_RADEON_9700PRO
;
269 gl_info
->gl_card
= CARD_ATI_RADEON_8500
;
274 gl_info
->gl_card
= CARD_WINE
;
278 TRACE_(d3d_caps
)("found GL_RENDERER (%s)->(0x%04x)\n", debugstr_a(gl_info
->gl_renderer
), gl_info
->gl_card
);
281 * Initialize openGL extension related variables
282 * with Default values
284 memset(&gl_info
->supported
, 0, sizeof(gl_info
->supported
));
285 gl_info
->max_textures
= 1;
286 gl_info
->ps_arb_version
= PS_VERSION_NOT_SUPPORTED
;
287 gl_info
->vs_arb_version
= VS_VERSION_NOT_SUPPORTED
;
288 gl_info
->vs_nv_version
= VS_VERSION_NOT_SUPPORTED
;
289 gl_info
->vs_ati_version
= VS_VERSION_NOT_SUPPORTED
;
291 /* Now work out what GL support this card really has */
292 #define USE_GL_FUNC(type, pfn) gl_info->pfn = NULL;
296 /* Retrieve opengl defaults */
297 glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
298 gl_info
->max_clipplanes
= min(D3DMAXUSERCLIPPLANES
, gl_max
);
299 TRACE_(d3d_caps
)("ClipPlanes support - num Planes=%d\n", gl_max
);
301 glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
302 gl_info
->max_lights
= gl_max
;
303 TRACE_(d3d_caps
)("Lights support - max lights=%d\n", gl_max
);
305 /* Parse the gl supported features, in theory enabling parts of our code appropriately */
306 GL_Extensions
= glGetString(GL_EXTENSIONS
);
307 TRACE_(d3d_caps
)("GL_Extensions reported:\n");
309 if (NULL
== GL_Extensions
) {
310 ERR(" GL_Extensions returns NULL\n");
312 while (*GL_Extensions
!= 0x00) {
313 const char *Start
= GL_Extensions
;
316 memset(ThisExtn
, 0x00, sizeof(ThisExtn
));
317 while (*GL_Extensions
!= ' ' && *GL_Extensions
!= 0x00) {
320 memcpy(ThisExtn
, Start
, (GL_Extensions
- Start
));
321 TRACE_(d3d_caps
)("- %s\n", ThisExtn
);
326 if (strcmp(ThisExtn
, "GL_ARB_fragment_program") == 0) {
327 gl_info
->ps_arb_version
= PS_VERSION_11
;
328 TRACE_(d3d_caps
)(" FOUND: ARB Pixel Shader support - version=%02x\n", gl_info
->ps_arb_version
);
329 gl_info
->supported
[ARB_FRAGMENT_PROGRAM
] = TRUE
;
330 } else if (strcmp(ThisExtn
, "GL_ARB_multisample") == 0) {
331 TRACE_(d3d_caps
)(" FOUND: ARB Multisample support\n");
332 gl_info
->supported
[ARB_MULTISAMPLE
] = TRUE
;
333 } else if (strcmp(ThisExtn
, "GL_ARB_multitexture") == 0) {
334 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
335 TRACE_(d3d_caps
)(" FOUND: ARB Multitexture support - GL_MAX_TEXTURE_UNITS_ARB=%u\n", gl_max
);
336 gl_info
->supported
[ARB_MULTITEXTURE
] = TRUE
;
337 gl_info
->max_textures
= min(8, gl_max
);
338 } else if (strcmp(ThisExtn
, "GL_ARB_texture_cube_map") == 0) {
339 TRACE_(d3d_caps
)(" FOUND: ARB Texture Cube Map support\n");
340 gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
] = TRUE
;
341 TRACE_(d3d_caps
)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support\n");
342 gl_info
->supported
[NV_TEXGEN_REFLECTION
] = TRUE
;
343 } else if (strcmp(ThisExtn
, "GL_ARB_texture_compression") == 0) {
344 TRACE_(d3d_caps
)(" FOUND: ARB Texture Compression support\n");
345 gl_info
->supported
[ARB_TEXTURE_COMPRESSION
] = TRUE
;
346 } else if (strcmp(ThisExtn
, "GL_ARB_texture_env_add") == 0) {
347 TRACE_(d3d_caps
)(" FOUND: ARB Texture Env Add support\n");
348 gl_info
->supported
[ARB_TEXTURE_ENV_ADD
] = TRUE
;
349 } else if (strcmp(ThisExtn
, "GL_ARB_texture_env_combine") == 0) {
350 TRACE_(d3d_caps
)(" FOUND: ARB Texture Env combine support\n");
351 gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
] = TRUE
;
352 } else if (strcmp(ThisExtn
, "GL_ARB_texture_env_dot3") == 0) {
353 TRACE_(d3d_caps
)(" FOUND: ARB Dot3 support\n");
354 gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
] = TRUE
;
355 } else if (strcmp(ThisExtn
, "GL_ARB_texture_border_clamp") == 0) {
356 TRACE_(d3d_caps
)(" FOUND: ARB Texture border clamp support\n");
357 gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
] = TRUE
;
358 } else if (strcmp(ThisExtn
, "GL_ARB_texture_mirrored_repeat") == 0) {
359 TRACE_(d3d_caps
)(" FOUND: ARB Texture mirrored repeat support\n");
360 gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
] = TRUE
;
361 } else if (strstr(ThisExtn
, "GL_ARB_vertex_program")) {
362 gl_info
->vs_arb_version
= VS_VERSION_11
;
363 TRACE_(d3d_caps
)(" FOUND: ARB Vertex Shader support - version=%02x\n", gl_info
->vs_arb_version
);
364 gl_info
->supported
[ARB_VERTEX_PROGRAM
] = TRUE
;
369 } else if (strcmp(ThisExtn
, "GL_EXT_fog_coord") == 0) {
370 TRACE_(d3d_caps
)(" FOUND: EXT Fog coord support\n");
371 gl_info
->supported
[EXT_FOG_COORD
] = TRUE
;
372 } else if (strcmp(ThisExtn
, "GL_EXT_paletted_texture") == 0) { /* handle paletted texture extensions */
373 TRACE_(d3d_caps
)(" FOUND: EXT Paletted texture support\n");
374 gl_info
->supported
[EXT_PALETTED_TEXTURE
] = TRUE
;
375 } else if (strcmp(ThisExtn
, "GL_EXT_point_parameters") == 0) {
376 TRACE_(d3d_caps
)(" FOUND: EXT Point parameters support\n");
377 gl_info
->supported
[EXT_POINT_PARAMETERS
] = TRUE
;
378 } else if (strcmp(ThisExtn
, "GL_EXT_secondary_color") == 0) {
379 TRACE_(d3d_caps
)(" FOUND: EXT Secondary coord support\n");
380 gl_info
->supported
[EXT_SECONDARY_COLOR
] = TRUE
;
381 } else if (strcmp(ThisExtn
, "GL_EXT_stencil_wrap") == 0) {
382 TRACE_(d3d_caps
)(" FOUND: EXT Stencil wrap support\n");
383 gl_info
->supported
[EXT_STENCIL_WRAP
] = TRUE
;
384 } else if (strcmp(ThisExtn
, "GL_EXT_texture_compression_s3tc") == 0) {
385 TRACE_(d3d_caps
)(" FOUND: EXT Texture S3TC compression support\n");
386 gl_info
->supported
[EXT_TEXTURE_COMPRESSION_S3TC
] = TRUE
;
387 } else if (strcmp(ThisExtn
, "GL_EXT_texture_env_add") == 0) {
388 TRACE_(d3d_caps
)(" FOUND: EXT Texture Env Add support\n");
389 gl_info
->supported
[EXT_TEXTURE_ENV_ADD
] = TRUE
;
390 } else if (strcmp(ThisExtn
, "GL_EXT_texture_env_combine") == 0) {
391 TRACE_(d3d_caps
)(" FOUND: EXT Texture Env combine support\n");
392 gl_info
->supported
[EXT_TEXTURE_ENV_COMBINE
] = TRUE
;
393 } else if (strcmp(ThisExtn
, "GL_EXT_texture_env_dot3") == 0) {
394 TRACE_(d3d_caps
)(" FOUND: EXT Dot3 support\n");
395 gl_info
->supported
[EXT_TEXTURE_ENV_DOT3
] = TRUE
;
396 } else if (strcmp(ThisExtn
, "GL_EXT_texture_filter_anisotropic") == 0) {
397 TRACE_(d3d_caps
)(" FOUND: EXT Texture Anisotropic filter support\n");
398 gl_info
->supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
] = TRUE
;
399 } else if (strcmp(ThisExtn
, "GL_EXT_texture_lod") == 0) {
400 TRACE_(d3d_caps
)(" FOUND: EXT Texture LOD support\n");
401 gl_info
->supported
[EXT_TEXTURE_LOD
] = TRUE
;
402 } else if (strcmp(ThisExtn
, "GL_EXT_texture_lod_bias") == 0) {
403 TRACE_(d3d_caps
)(" FOUND: EXT Texture LOD bias support\n");
404 gl_info
->supported
[EXT_TEXTURE_LOD_BIAS
] = TRUE
;
405 } else if (strcmp(ThisExtn
, "GL_EXT_vertex_weighting") == 0) {
406 TRACE_(d3d_caps
)(" FOUND: EXT Vertex weighting support\n");
407 gl_info
->supported
[EXT_VERTEX_WEIGHTING
] = TRUE
;
412 } else if (strstr(ThisExtn
, "GL_NV_fog_distance")) {
413 TRACE_(d3d_caps
)(" FOUND: NVIDIA (NV) Fog Distance support\n");
414 gl_info
->supported
[NV_FOG_DISTANCE
] = TRUE
;
415 } else if (strstr(ThisExtn
, "GL_NV_fragment_program")) {
416 gl_info
->ps_nv_version
= PS_VERSION_11
;
417 TRACE_(d3d_caps
)(" FOUND: NVIDIA (NV) Pixel Shader support - version=%02x\n", gl_info
->ps_nv_version
);
418 } else if (strcmp(ThisExtn
, "GL_NV_register_combiners") == 0) {
419 TRACE_(d3d_caps
)(" FOUND: NVIDIA (NV) Register combiners (1) support\n");
420 gl_info
->supported
[NV_REGISTER_COMBINERS
] = TRUE
;
421 } else if (strcmp(ThisExtn
, "GL_NV_register_combiners2") == 0) {
422 TRACE_(d3d_caps
)(" FOUND: NVIDIA (NV) Register combiners (2) support\n");
423 gl_info
->supported
[NV_REGISTER_COMBINERS2
] = TRUE
;
424 } else if (strcmp(ThisExtn
, "GL_NV_texgen_reflection") == 0) {
425 TRACE_(d3d_caps
)(" FOUND: NVIDIA (NV) Texture Gen Reflection support\n");
426 gl_info
->supported
[NV_TEXGEN_REFLECTION
] = TRUE
;
427 } else if (strcmp(ThisExtn
, "GL_NV_texture_env_combine4") == 0) {
428 TRACE_(d3d_caps
)(" FOUND: NVIDIA (NV) Texture Env combine (4) support\n");
429 gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
] = TRUE
;
430 } else if (strcmp(ThisExtn
, "GL_NV_texture_shader") == 0) {
431 TRACE_(d3d_caps
)(" FOUND: NVIDIA (NV) Texture Shader (1) support\n");
432 gl_info
->supported
[NV_TEXTURE_SHADER
] = TRUE
;
433 } else if (strcmp(ThisExtn
, "GL_NV_texture_shader2") == 0) {
434 TRACE_(d3d_caps
)(" FOUND: NVIDIA (NV) Texture Shader (2) support\n");
435 gl_info
->supported
[NV_TEXTURE_SHADER2
] = TRUE
;
436 } else if (strcmp(ThisExtn
, "GL_NV_texture_shader3") == 0) {
437 TRACE_(d3d_caps
)(" FOUND: NVIDIA (NV) Texture Shader (3) support\n");
438 gl_info
->supported
[NV_TEXTURE_SHADER3
] = TRUE
;
439 } else if (strstr(ThisExtn
, "GL_NV_vertex_program")) {
440 gl_info
->vs_nv_version
= max(gl_info
->vs_nv_version
, (0 == strcmp(ThisExtn
, "GL_NV_vertex_program1_1")) ? VS_VERSION_11
: VS_VERSION_10
);
441 gl_info
->vs_nv_version
= max(gl_info
->vs_nv_version
, (0 == strcmp(ThisExtn
, "GL_NV_vertex_program2")) ? VS_VERSION_20
: VS_VERSION_10
);
442 TRACE_(d3d_caps
)(" FOUND: NVIDIA (NV) Vertex Shader support - version=%02x\n", gl_info
->vs_nv_version
);
443 gl_info
->supported
[NV_VERTEX_PROGRAM
] = TRUE
;
449 } else if (strcmp(ThisExtn
, "GL_ATI_texture_env_combine3") == 0) {
450 TRACE_(d3d_caps
)(" FOUND: ATI Texture Env combine (3) support\n");
451 gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
] = TRUE
;
452 } else if (strcmp(ThisExtn
, "GL_ATI_texture_mirror_once") == 0) {
453 TRACE_(d3d_caps
)(" FOUND: ATI Texture Mirror Once support\n");
454 gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] = TRUE
;
455 } else if (strcmp(ThisExtn
, "GL_EXT_vertex_shader") == 0) {
456 gl_info
->vs_ati_version
= VS_VERSION_11
;
457 TRACE_(d3d_caps
)(" FOUND: ATI (EXT) Vertex Shader support - version=%02x\n", gl_info
->vs_ati_version
);
458 gl_info
->supported
[EXT_VERTEX_SHADER
] = TRUE
;
462 if (*GL_Extensions
== ' ') GL_Extensions
++;
466 #define USE_GL_FUNC(type, pfn) gl_info->pfn = (type) glXGetProcAddressARB(#pfn);
470 if (display
!= NULL
) {
471 GLX_Extensions
= glXQueryExtensionsString(display
, DefaultScreen(display
));
472 TRACE_(d3d_caps
)("GLX_Extensions reported:\n");
474 if (NULL
== GLX_Extensions
) {
475 ERR(" GLX_Extensions returns NULL\n");
477 while (*GLX_Extensions
!= 0x00) {
478 const char *Start
= GLX_Extensions
;
481 memset(ThisExtn
, 0x00, sizeof(ThisExtn
));
482 while (*GLX_Extensions
!= ' ' && *GLX_Extensions
!= 0x00) {
485 memcpy(ThisExtn
, Start
, (GLX_Extensions
- Start
));
486 TRACE_(d3d_caps
)("- %s\n", ThisExtn
);
487 if (*GLX_Extensions
== ' ') GLX_Extensions
++;
492 #define USE_GL_FUNC(type, pfn) gl_info->pfn = (type) glXGetProcAddressARB(#pfn);
496 /* Only save the values obtained when a display is provided */
497 if (display
!= NULL
) {
504 /**********************************************************
505 * IWineD3D implementation follows
506 **********************************************************/
508 UINT WINAPI
IWineD3DImpl_GetAdapterCount (IWineD3D
*iface
) {
509 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
511 /* FIXME: Set to one for now to imply the display */
512 TRACE_(d3d_caps
)("(%p): Mostly stub, only returns primary display\n", This
);
516 HRESULT WINAPI
IWineD3DImpl_RegisterSoftwareDevice(IWineD3D
*iface
, void* pInitializeFunction
) {
517 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
518 FIXME("(%p)->(%p): stub\n", This
, pInitializeFunction
);
522 HMONITOR WINAPI
IWineD3DImpl_GetAdapterMonitor(IWineD3D
*iface
, UINT Adapter
) {
523 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
524 FIXME_(d3d_caps
)("(%p)->(Adptr:%d)\n", This
, Adapter
);
525 if (Adapter
>= IWineD3DImpl_GetAdapterCount(iface
)) {
531 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
532 of the same bpp but different resolutions */
534 /* Note: dx9 supplies a format. Calls from d3d8 supply D3DFMT_UNKNOWN */
535 UINT WINAPI
IWineD3DImpl_GetAdapterModeCount(IWineD3D
*iface
, UINT Adapter
, D3DFORMAT Format
) {
536 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
537 TRACE_(d3d_caps
)("(%p}->(Adapter: %d, Format: %s)\n", This
, Adapter
, debug_d3dformat(Format
));
539 if (Adapter
>= IWineD3D_GetAdapterCount(iface
)) {
543 if (Adapter
== 0) { /* Display */
546 #if !defined( DEBUG_SINGLE_MODE )
549 /* Work out the current screen bpp */
550 HDC hdc
= CreateDCA("DISPLAY", NULL
, NULL
, NULL
);
551 int bpp
= GetDeviceCaps(hdc
, BITSPIXEL
);
554 while (EnumDisplaySettingsExW(NULL
, j
, &DevModeW
, 0)) {
561 case D3DFMT_X8R8G8B8
:
562 case D3DFMT_A8R8G8B8
:
563 if (min(DevModeW
.dmBitsPerPel
, bpp
) == 32) i
++;
565 case D3DFMT_X1R5G5B5
:
566 case D3DFMT_A1R5G5B5
:
568 if (min(DevModeW
.dmBitsPerPel
, bpp
) == 16) i
++;
571 /* Skip other modes as they do not match requested format */
579 TRACE_(d3d_caps
)("(%p}->(Adapter: %d) => %d (out of %d)\n", This
, Adapter
, i
, j
);
582 FIXME_(d3d_caps
)("Adapter not primary display\n");
587 /* Note: dx9 supplies a format. Calls from d3d8 supply D3DFMT_UNKNOWN */
588 HRESULT WINAPI
IWineD3DImpl_EnumAdapterModes(IWineD3D
*iface
, UINT Adapter
, D3DFORMAT Format
, UINT Mode
, D3DDISPLAYMODE
* pMode
) {
589 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
590 TRACE_(d3d_caps
)("(%p}->(Adapter:%d, mode:%d, pMode:%p, format:%s)\n", This
, Adapter
, Mode
, pMode
, debug_d3dformat(Format
));
592 /* Validate the parameters as much as possible */
594 Adapter
>= IWineD3DImpl_GetAdapterCount(iface
) ||
595 Mode
>= IWineD3DImpl_GetAdapterModeCount(iface
, Adapter
, Format
)) {
596 return D3DERR_INVALIDCALL
;
599 if (Adapter
== 0) { /* Display */
600 #if !defined( DEBUG_SINGLE_MODE )
604 /* Work out the current screen bpp */
605 HDC hdc
= CreateDCA("DISPLAY", NULL
, NULL
, NULL
);
606 int bpp
= GetDeviceCaps(hdc
, BITSPIXEL
);
609 /* If we are filtering to a specific format, then need to skip all unrelated
610 modes, but if mode is irrelevant, then we can use the index directly */
611 if (Format
== D3DFMT_UNKNOWN
)
617 DEVMODEW DevModeWtmp
;
620 while ((Mode
+1) < i
&& EnumDisplaySettingsExW(NULL
, j
, &DevModeWtmp
, 0)) {
627 case D3DFMT_X8R8G8B8
:
628 case D3DFMT_A8R8G8B8
:
629 if (min(DevModeWtmp
.dmBitsPerPel
, bpp
) == 32) i
++;
631 case D3DFMT_X1R5G5B5
:
632 case D3DFMT_A1R5G5B5
:
634 if (min(DevModeWtmp
.dmBitsPerPel
, bpp
) == 16) i
++;
637 /* Skip other modes as they do not match requested format */
644 /* Now get the display mode via the calculated index */
645 if (EnumDisplaySettingsExW(NULL
, ModeIdx
, &DevModeW
, 0))
647 pMode
->Width
= DevModeW
.dmPelsWidth
;
648 pMode
->Height
= DevModeW
.dmPelsHeight
;
649 bpp
= min(DevModeW
.dmBitsPerPel
, bpp
);
650 pMode
->RefreshRate
= D3DADAPTER_DEFAULT
;
651 if (DevModeW
.dmFields
&DM_DISPLAYFREQUENCY
)
653 pMode
->RefreshRate
= DevModeW
.dmDisplayFrequency
;
656 if (Format
== D3DFMT_UNKNOWN
)
659 case 8: pMode
->Format
= D3DFMT_R3G3B2
; break;
660 case 16: pMode
->Format
= D3DFMT_R5G6B5
; break;
661 case 24: /* pMode->Format = D3DFMT_R5G6B5; break;*/ /* Make 24bit appear as 32 bit */
662 case 32: pMode
->Format
= D3DFMT_A8R8G8B8
; break;
663 default: pMode
->Format
= D3DFMT_UNKNOWN
;
666 pMode
->Format
= Format
;
671 TRACE_(d3d_caps
)("Requested mode out of range %d\n", Mode
);
672 return D3DERR_INVALIDCALL
;
676 /* Return one setting of the format requested */
677 if (Mode
> 0) return D3DERR_INVALIDCALL
;
680 pMode
->RefreshRate
= D3DADAPTER_DEFAULT
;
681 pMode
->Format
= (Format
==D3DFMT_UNKNOWN
)?D3DFMT_A8R8G8B8
:Format
;
684 TRACE_(d3d_caps
)("W %d H %d rr %d fmt (%x - %s) bpp %u\n", pMode
->Width
, pMode
->Height
,
685 pMode
->RefreshRate
, pMode
->Format
, debug_d3dformat(pMode
->Format
), bpp
);
688 FIXME_(d3d_caps
)("Adapter not primary display\n");
694 HRESULT WINAPI
IWineD3DImpl_GetAdapterDisplayMode(IWineD3D
*iface
, UINT Adapter
, D3DDISPLAYMODE
* pMode
) {
695 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
696 TRACE_(d3d_caps
)("(%p}->(Adapter: %d, pMode: %p)\n", This
, Adapter
, pMode
);
699 Adapter
>= IWineD3D_GetAdapterCount(iface
)) {
700 return D3DERR_INVALIDCALL
;
703 if (Adapter
== 0) { /* Display */
707 EnumDisplaySettingsExW(NULL
, (DWORD
)-1, &DevModeW
, 0);
708 pMode
->Width
= DevModeW
.dmPelsWidth
;
709 pMode
->Height
= DevModeW
.dmPelsHeight
;
710 bpp
= DevModeW
.dmBitsPerPel
;
711 pMode
->RefreshRate
= D3DADAPTER_DEFAULT
;
712 if (DevModeW
.dmFields
&DM_DISPLAYFREQUENCY
)
714 pMode
->RefreshRate
= DevModeW
.dmDisplayFrequency
;
718 case 8: pMode
->Format
= D3DFMT_R3G3B2
; break;
719 case 16: pMode
->Format
= D3DFMT_R5G6B5
; break;
720 case 24: /*pMode->Format = D3DFMT_R5G6B5; break;*/ /* Make 24bit appear as 32 bit */
721 case 32: pMode
->Format
= D3DFMT_A8R8G8B8
; break;
722 default: pMode
->Format
= D3DFMT_UNKNOWN
;
726 FIXME_(d3d_caps
)("Adapter not primary display\n");
729 TRACE_(d3d_caps
)("returning w:%d, h:%d, ref:%d, fmt:%s\n", pMode
->Width
,
730 pMode
->Height
, pMode
->RefreshRate
, debug_d3dformat(pMode
->Format
));
734 /* Note due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
735 and fields being inserted in the middle, a new structure is used in place */
736 HRESULT WINAPI
IWineD3DImpl_GetAdapterIdentifier(IWineD3D
*iface
, UINT Adapter
, DWORD Flags
,
737 WINED3DADAPTER_IDENTIFIER
* pIdentifier
) {
738 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
740 TRACE_(d3d_caps
)("(%p}->(Adapter: %d, Flags: %lx, pId=%p)\n", This
, Adapter
, Flags
, pIdentifier
);
742 if (Adapter
>= IWineD3D_GetAdapterCount(iface
)) {
743 return D3DERR_INVALIDCALL
;
746 if (Adapter
== 0) { /* Display - only device supported for now */
748 BOOL isGLInfoValid
= This
->isGLInfoValid
;
750 /* FillGLCaps updates gl_info, but we only want to store and
751 reuse the values once we have a context which is valid. Values from
752 a temporary context may differ from the final ones */
753 if (isGLInfoValid
== FALSE
) {
755 /* If we don't know the device settings, go query them now via a
757 WineD3D_Context
* ctx
= WineD3D_CreateFakeGLContext();
759 isGLInfoValid
= IWineD3DImpl_FillGLCaps(&This
->gl_info
, ctx
->display
);
760 WineD3D_ReleaseFakeGLContext(ctx
);
764 /* If it worked, return the information requested */
765 if (isGLInfoValid
== TRUE
) {
766 TRACE_(d3d_caps
)("device/Vendor Name and Version detection using FillGLCaps\n");
767 strcpy(pIdentifier
->Driver
, "Display");
768 strcpy(pIdentifier
->Description
, "Direct3D HAL");
770 /* Note dx8 doesn't supply a DeviceName */
771 if (NULL
!= pIdentifier
->DeviceName
) strcpy(pIdentifier
->DeviceName
, "\\\\.\\DISPLAY"); /* FIXME: May depend on desktop? */
772 pIdentifier
->DriverVersion
->u
.HighPart
= 0xa;
773 pIdentifier
->DriverVersion
->u
.LowPart
= This
->gl_info
.gl_driver_version
;
774 *(pIdentifier
->VendorId
) = This
->gl_info
.gl_vendor
;
775 *(pIdentifier
->DeviceId
) = This
->gl_info
.gl_card
;
776 *(pIdentifier
->SubSysId
) = 0;
777 *(pIdentifier
->Revision
) = 0;
781 /* If it failed, return dummy values from an NVidia driver */
782 WARN_(d3d_caps
)("Cannot get GLCaps for device/Vendor Name and Version detection using FillGLCaps, currently using NVIDIA identifiers\n");
783 strcpy(pIdentifier
->Driver
, "Display");
784 strcpy(pIdentifier
->Description
, "Direct3D HAL");
785 if (NULL
!= pIdentifier
->DeviceName
) strcpy(pIdentifier
->DeviceName
, "\\\\.\\DISPLAY"); /* FIXME: May depend on desktop? */
786 pIdentifier
->DriverVersion
->u
.HighPart
= 0xa;
787 pIdentifier
->DriverVersion
->u
.LowPart
= MAKEDWORD_VERSION(53, 96); /* last Linux Nvidia drivers */
788 *(pIdentifier
->VendorId
) = VENDOR_NVIDIA
;
789 *(pIdentifier
->DeviceId
) = CARD_NVIDIA_GEFORCE4_TI4600
;
790 *(pIdentifier
->SubSysId
) = 0;
791 *(pIdentifier
->Revision
) = 0;
794 /*FIXME: memcpy(&pIdentifier->DeviceIdentifier, ??, sizeof(??GUID)); */
795 if (Flags
& D3DENUM_NO_WHQL_LEVEL
) {
796 *(pIdentifier
->WHQLLevel
) = 0;
798 *(pIdentifier
->WHQLLevel
) = 1;
802 FIXME_(d3d_caps
)("Adapter not primary display\n");
808 HRESULT WINAPI
IWineD3DImpl_CheckDepthStencilMatch(IWineD3D
*iface
, UINT Adapter
, D3DDEVTYPE DeviceType
,
809 D3DFORMAT AdapterFormat
, D3DFORMAT RenderTargetFormat
, D3DFORMAT DepthStencilFormat
) {
810 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
811 WARN_(d3d_caps
)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n",
813 DeviceType
, debug_d3ddevicetype(DeviceType
),
814 AdapterFormat
, debug_d3dformat(AdapterFormat
),
815 RenderTargetFormat
, debug_d3dformat(RenderTargetFormat
),
816 DepthStencilFormat
, debug_d3dformat(DepthStencilFormat
));
818 if (Adapter
>= IWineD3D_GetAdapterCount(iface
)) {
819 return D3DERR_INVALIDCALL
;
825 HRESULT WINAPI
IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D
*iface
,
826 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT SurfaceFormat
,
827 BOOL Windowed
, D3DMULTISAMPLE_TYPE MultiSampleType
, DWORD
* pQualityLevels
) {
829 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
830 TRACE_(d3d_caps
)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x, pQual:%p)\n",
833 DeviceType
, debug_d3ddevicetype(DeviceType
),
834 SurfaceFormat
, debug_d3dformat(SurfaceFormat
),
839 if (Adapter
>= IWineD3D_GetAdapterCount(iface
)) {
840 return D3DERR_INVALIDCALL
;
843 if (pQualityLevels
!= NULL
) {
844 FIXME("Quality levels unsupported at present\n");
845 *pQualityLevels
= 1; /* Guess at a value! */
848 if (D3DMULTISAMPLE_NONE
== MultiSampleType
)
850 return D3DERR_NOTAVAILABLE
;
853 HRESULT WINAPI
IWineD3DImpl_CheckDeviceType(IWineD3D
*iface
,
854 UINT Adapter
, D3DDEVTYPE CheckType
, D3DFORMAT DisplayFormat
,
855 D3DFORMAT BackBufferFormat
, BOOL Windowed
) {
857 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
858 TRACE_(d3d_caps
)("(%p)-> (STUB) (Adptr:%d, CheckType:(%x,%s), DispFmt:(%x,%s), BackBuf:(%x,%s), Win?%d): stub\n",
861 CheckType
, debug_d3ddevicetype(CheckType
),
862 DisplayFormat
, debug_d3dformat(DisplayFormat
),
863 BackBufferFormat
, debug_d3dformat(BackBufferFormat
),
866 if (Adapter
>= IWineD3D_GetAdapterCount(iface
)) {
867 return D3DERR_INVALIDCALL
;
870 switch (DisplayFormat
) {
871 /*case D3DFMT_R5G6B5:*/
873 return D3DERR_NOTAVAILABLE
;
880 HRESULT WINAPI
IWineD3DImpl_CheckDeviceFormat(IWineD3D
*iface
,
881 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT AdapterFormat
,
882 DWORD Usage
, D3DRESOURCETYPE RType
, D3DFORMAT CheckFormat
) {
883 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
884 TRACE_(d3d_caps
)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), AdptFmt:(%u,%s), Use:(%lu,%s), ResTyp:(%x,%s), CheckFmt:(%u,%s)) ",
887 DeviceType
, debug_d3ddevicetype(DeviceType
),
888 AdapterFormat
, debug_d3dformat(AdapterFormat
),
889 Usage
, debug_d3dusage(Usage
),
890 RType
, debug_d3dresourcetype(RType
),
891 CheckFormat
, debug_d3dformat(CheckFormat
));
893 if (Adapter
>= IWineD3D_GetAdapterCount(iface
)) {
894 return D3DERR_INVALIDCALL
;
897 if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC
)) {
898 switch (CheckFormat
) {
902 TRACE_(d3d_caps
)("[OK]\n");
905 break; /* Avoid compiler warnings */
909 switch (CheckFormat
) {
911 * check supported using GL_SUPPORT
922 /*case D3DFMT_R5G6B5: */
923 /*case D3DFMT_X1R5G5B5:*/
924 /*case D3DFMT_A1R5G5B5: */
925 /*case D3DFMT_A4R4G4B4:*/
932 /*case D3DFMT_X8R8G8B8:*/
933 case D3DFMT_A8R3G3B2
:
950 case D3DFMT_X8L8V8U8
:
951 case D3DFMT_Q8W8V8U8
:
952 case D3DFMT_W11V11U10
:
955 * currently hard to support
960 /* Since we do not support these formats right now, don't pretend to. */
961 TRACE_(d3d_caps
)("[FAILED]\n");
962 return D3DERR_NOTAVAILABLE
;
967 TRACE_(d3d_caps
)("[OK]\n");
971 HRESULT WINAPI
IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D
*iface
, UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT SourceFormat
, D3DFORMAT TargetFormat
) {
972 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
974 FIXME_(d3d_caps
)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), SrcFmt:(%u,%s), TgtFmt:(%u,%s))",
977 DeviceType
, debug_d3ddevicetype(DeviceType
),
978 SourceFormat
, debug_d3dformat(SourceFormat
),
979 TargetFormat
, debug_d3dformat(TargetFormat
));
983 /* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
984 subset of a D3DCAPS9 structure. However, it has to come via a void *
985 as the d3d8 interface cannot import the d3d9 header */
986 HRESULT WINAPI
IWineD3DImpl_GetDeviceCaps(IWineD3D
*iface
, UINT Adapter
, D3DDEVTYPE DeviceType
, void* pCapsIn
) {
988 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
989 BOOL gotContext
= FALSE
;
990 GLint gl_tex_size
= 0;
991 WineD3D_Context
*fake_ctx
= NULL
;
992 D3DCAPS9
*pCaps
= (D3DCAPS9
*)pCapsIn
;
994 TRACE_(d3d_caps
)("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This
, Adapter
, DeviceType
, pCaps
);
996 if (Adapter
>= IWineD3D_GetAdapterCount(iface
)) {
997 return D3DERR_INVALIDCALL
;
1000 /* Note: GL seems to trap if GetDeviceCaps is called before any HWND's created
1001 ie there is no GL Context - Get a default rendering context to enable the
1002 function query some info from GL */
1003 if (glXGetCurrentContext() == NULL
) {
1004 fake_ctx
= WineD3D_CreateFakeGLContext();
1005 if (NULL
!= fake_ctx
) gotContext
= TRUE
;
1010 if (gotContext
== FALSE
) {
1012 FIXME_(d3d_caps
)("GetDeviceCaps called but no GL Context - Returning dummy values\n");
1014 pCaps
->MaxTextureBlendStages
= 2;
1015 pCaps
->MaxSimultaneousTextures
= 2;
1016 pCaps
->MaxUserClipPlanes
= 8;
1017 pCaps
->MaxActiveLights
= 8;
1018 pCaps
->MaxVertexBlendMatrices
= 0;
1019 pCaps
->MaxVertexBlendMatrixIndex
= 1;
1020 pCaps
->MaxAnisotropy
= 0;
1021 pCaps
->MaxPointSize
= 255.0;
1023 glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &gl_tex_size
);
1026 /* If we don't know the device settings, go query them now */
1027 if (This
->isGLInfoValid
== FALSE
) {
1028 BOOL rc
= IWineD3DImpl_FillGLCaps(&This
->gl_info
, NULL
);
1030 /* If we are running off a real context, save the values */
1031 if ((rc
== TRUE
) && ((NULL
!= fake_ctx
))) This
->isGLInfoValid
= TRUE
;
1034 /* ------------------------------------------------
1035 The following fields apply to both d3d8 and d3d9
1036 ------------------------------------------------ */
1037 pCaps
->DeviceType
= (DeviceType
== D3DDEVTYPE_HAL
) ? D3DDEVTYPE_HAL
: D3DDEVTYPE_REF
; /* Not quite true, but use h/w supported by opengl I suppose */
1038 pCaps
->AdapterOrdinal
= Adapter
;
1041 pCaps
->Caps2
= D3DCAPS2_CANRENDERWINDOWED
;
1042 pCaps
->Caps3
= D3DDEVCAPS_HWTRANSFORMANDLIGHT
;
1043 pCaps
->PresentationIntervals
= D3DPRESENT_INTERVAL_IMMEDIATE
;
1045 pCaps
->CursorCaps
= 0;
1047 pCaps
->DevCaps
= D3DDEVCAPS_DRAWPRIMTLVERTEX
|
1048 D3DDEVCAPS_HWTRANSFORMANDLIGHT
|
1049 D3DDEVCAPS_PUREDEVICE
;
1051 pCaps
->PrimitiveMiscCaps
= D3DPMISCCAPS_CULLCCW
|
1052 D3DPMISCCAPS_CULLCW
|
1053 D3DPMISCCAPS_COLORWRITEENABLE
|
1054 D3DPMISCCAPS_CLIPTLVERTS
|
1055 D3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
1057 /*NOT: D3DPMISCCAPS_TSSARGTEMP*/
1059 pCaps
->RasterCaps
= D3DPRASTERCAPS_DITHER
|
1060 D3DPRASTERCAPS_PAT
|
1061 D3DPRASTERCAPS_WFOG
|
1062 D3DPRASTERCAPS_ZFOG
|
1063 D3DPRASTERCAPS_FOGVERTEX
|
1064 D3DPRASTERCAPS_FOGTABLE
|
1065 D3DPRASTERCAPS_FOGRANGE
;
1067 if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC
)) {
1068 pCaps
->RasterCaps
|= D3DPRASTERCAPS_ANISOTROPY
;
1071 D3DPRASTERCAPS_MIPMAPLODBIAS
1072 D3DPRASTERCAPS_ZBIAS
1073 D3DPRASTERCAPS_COLORPERSPECTIVE
1074 D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
1075 D3DPRASTERCAPS_ANTIALIASEDGES
1076 D3DPRASTERCAPS_ZBUFFERLESSHSR
1077 D3DPRASTERCAPS_WBUFFER */
1079 pCaps
->ZCmpCaps
= D3DPCMPCAPS_ALWAYS
|
1081 D3DPCMPCAPS_GREATER
|
1082 D3DPCMPCAPS_GREATEREQUAL
|
1084 D3DPCMPCAPS_LESSEQUAL
|
1086 D3DPCMPCAPS_NOTEQUAL
;
1088 pCaps
->SrcBlendCaps
= 0xFFFFFFFF; /*FIXME: Tidy up later */
1089 pCaps
->DestBlendCaps
= 0xFFFFFFFF; /*FIXME: Tidy up later */
1090 pCaps
->AlphaCmpCaps
= 0xFFFFFFFF; /*FIXME: Tidy up later */
1092 pCaps
->ShadeCaps
= D3DPSHADECAPS_SPECULARGOURAUDRGB
|
1093 D3DPSHADECAPS_COLORGOURAUDRGB
;
1095 pCaps
->TextureCaps
= D3DPTEXTURECAPS_ALPHA
|
1096 D3DPTEXTURECAPS_ALPHAPALETTE
|
1097 D3DPTEXTURECAPS_POW2
|
1098 D3DPTEXTURECAPS_VOLUMEMAP
|
1099 D3DPTEXTURECAPS_MIPMAP
|
1100 D3DPTEXTURECAPS_PROJECTED
;
1102 if (GL_SUPPORT(ARB_TEXTURE_CUBE_MAP
)) {
1103 pCaps
->TextureCaps
|= D3DPTEXTURECAPS_CUBEMAP
|
1104 D3DPTEXTURECAPS_MIPCUBEMAP
|
1105 D3DPTEXTURECAPS_CUBEMAP_POW2
;
1108 pCaps
->TextureFilterCaps
= D3DPTFILTERCAPS_MAGFLINEAR
|
1109 D3DPTFILTERCAPS_MAGFPOINT
|
1110 D3DPTFILTERCAPS_MINFLINEAR
|
1111 D3DPTFILTERCAPS_MINFPOINT
|
1112 D3DPTFILTERCAPS_MIPFLINEAR
|
1113 D3DPTFILTERCAPS_MIPFPOINT
;
1115 pCaps
->CubeTextureFilterCaps
= 0;
1116 pCaps
->VolumeTextureFilterCaps
= 0;
1118 pCaps
->TextureAddressCaps
= D3DPTADDRESSCAPS_BORDER
|
1119 D3DPTADDRESSCAPS_CLAMP
|
1120 D3DPTADDRESSCAPS_WRAP
;
1122 if (GL_SUPPORT(ARB_TEXTURE_BORDER_CLAMP
)) {
1123 pCaps
->TextureAddressCaps
|= D3DPTADDRESSCAPS_BORDER
;
1125 if (GL_SUPPORT(ARB_TEXTURE_MIRRORED_REPEAT
)) {
1126 pCaps
->TextureAddressCaps
|= D3DPTADDRESSCAPS_MIRROR
;
1128 if (GL_SUPPORT(ATI_TEXTURE_MIRROR_ONCE
)) {
1129 pCaps
->TextureAddressCaps
|= D3DPTADDRESSCAPS_MIRRORONCE
;
1132 pCaps
->VolumeTextureAddressCaps
= 0;
1134 pCaps
->LineCaps
= D3DLINECAPS_TEXTURE
|
1138 D3DLINECAPS_ALPHACMP
1141 pCaps
->MaxTextureWidth
= gl_tex_size
;
1142 pCaps
->MaxTextureHeight
= gl_tex_size
;
1144 pCaps
->MaxVolumeExtent
= 0;
1146 pCaps
->MaxTextureRepeat
= 32768;
1147 pCaps
->MaxTextureAspectRatio
= 32768;
1148 pCaps
->MaxVertexW
= 1.0;
1150 pCaps
->GuardBandLeft
= 0;
1151 pCaps
->GuardBandTop
= 0;
1152 pCaps
->GuardBandRight
= 0;
1153 pCaps
->GuardBandBottom
= 0;
1155 pCaps
->ExtentsAdjust
= 0;
1157 pCaps
->StencilCaps
= D3DSTENCILCAPS_DECRSAT
|
1158 D3DSTENCILCAPS_INCRSAT
|
1159 D3DSTENCILCAPS_INVERT
|
1160 D3DSTENCILCAPS_KEEP
|
1161 D3DSTENCILCAPS_REPLACE
|
1162 D3DSTENCILCAPS_ZERO
;
1163 if (GL_SUPPORT(EXT_STENCIL_WRAP
)) {
1164 pCaps
->StencilCaps
|= D3DSTENCILCAPS_DECR
|
1165 D3DSTENCILCAPS_INCR
;
1168 pCaps
->FVFCaps
= D3DFVFCAPS_PSIZE
| 0x0008; /* 8 texture coords */
1170 pCaps
->TextureOpCaps
= D3DTEXOPCAPS_ADD
|
1171 D3DTEXOPCAPS_ADDSIGNED
|
1172 D3DTEXOPCAPS_ADDSIGNED2X
|
1173 D3DTEXOPCAPS_MODULATE
|
1174 D3DTEXOPCAPS_MODULATE2X
|
1175 D3DTEXOPCAPS_MODULATE4X
|
1176 D3DTEXOPCAPS_SELECTARG1
|
1177 D3DTEXOPCAPS_SELECTARG2
|
1178 D3DTEXOPCAPS_DISABLE
;
1179 #if defined(GL_VERSION_1_3)
1180 pCaps
->TextureOpCaps
|= D3DTEXOPCAPS_DOTPRODUCT3
|
1181 D3DTEXOPCAPS_SUBTRACT
;
1183 if (GL_SUPPORT(ARB_TEXTURE_ENV_COMBINE
) ||
1184 GL_SUPPORT(EXT_TEXTURE_ENV_COMBINE
) ||
1185 GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4
)) {
1186 pCaps
->TextureOpCaps
|= D3DTEXOPCAPS_BLENDDIFFUSEALPHA
|
1187 D3DTEXOPCAPS_BLENDTEXTUREALPHA
|
1188 D3DTEXOPCAPS_BLENDFACTORALPHA
|
1189 D3DTEXOPCAPS_BLENDCURRENTALPHA
|
1192 if (GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4
)) {
1193 pCaps
->TextureOpCaps
|= D3DTEXOPCAPS_ADDSMOOTH
|
1194 D3DTEXOPCAPS_MULTIPLYADD
|
1195 D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
|
1196 D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
|
1197 D3DTEXOPCAPS_BLENDTEXTUREALPHAPM
;
1201 pCaps
->TextureOpCaps
|= D3DTEXOPCAPS_BUMPENVMAP
;
1203 D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
1204 D3DTEXOPCAPS_PREMODULATE */
1210 #if defined(GL_VERSION_1_3)
1211 glGetIntegerv(GL_MAX_TEXTURE_UNITS
, &gl_max
);
1213 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
1215 TRACE_(d3d_caps
)("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max
);
1216 pCaps
->MaxTextureBlendStages
= min(8, gl_max
);
1217 pCaps
->MaxSimultaneousTextures
= min(8, gl_max
);
1219 glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
1220 pCaps
->MaxUserClipPlanes
= min(D3DMAXUSERCLIPPLANES
, gl_max
);
1221 TRACE_(d3d_caps
)("GLCaps: GL_MAX_CLIP_PLANES=%ld\n", pCaps
->MaxUserClipPlanes
);
1223 glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
1224 pCaps
->MaxActiveLights
= gl_max
;
1225 TRACE_(d3d_caps
)("GLCaps: GL_MAX_LIGHTS=%ld\n", pCaps
->MaxActiveLights
);
1227 if (GL_SUPPORT(ARB_VERTEX_BLEND
)) {
1228 glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB
, &gl_max
);
1229 pCaps
->MaxVertexBlendMatrices
= gl_max
;
1230 pCaps
->MaxVertexBlendMatrixIndex
= 1;
1232 pCaps
->MaxVertexBlendMatrices
= 0;
1233 pCaps
->MaxVertexBlendMatrixIndex
= 1;
1236 if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC
)) {
1237 glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, &gl_max
);
1238 pCaps
->MaxAnisotropy
= gl_max
;
1240 pCaps
->MaxAnisotropy
= 0;
1243 glGetFloatv(GL_POINT_SIZE_RANGE
, &gl_float
);
1244 pCaps
->MaxPointSize
= gl_float
;
1247 pCaps
->VertexProcessingCaps
= D3DVTXPCAPS_DIRECTIONALLIGHTS
|
1248 D3DVTXPCAPS_MATERIALSOURCE7
|
1249 D3DVTXPCAPS_POSITIONALLIGHTS
|
1250 D3DVTXPCAPS_LOCALVIEWER
|
1253 D3DVTXPCAPS_TWEENING */
1255 pCaps
->MaxPrimitiveCount
= 0xFFFFFFFF;
1256 pCaps
->MaxVertexIndex
= 0xFFFFFFFF;
1257 pCaps
->MaxStreams
= MAX_STREAMS
;
1258 pCaps
->MaxStreamStride
= 1024;
1260 if (((vs_mode
== VS_HW
) && GL_SUPPORT(ARB_VERTEX_PROGRAM
)) || (vs_mode
== VS_SW
) || (DeviceType
== D3DDEVTYPE_REF
)) {
1261 pCaps
->VertexShaderVersion
= D3DVS_VERSION(1,1);
1263 if (This
->gl_info
.gl_vendor
== VENDOR_MESA
||
1264 This
->gl_info
.gl_vendor
== VENDOR_WINE
) {
1265 pCaps
->MaxVertexShaderConst
= 95;
1267 pCaps
->MaxVertexShaderConst
= WINED3D_VSHADER_MAX_CONSTANTS
;
1270 pCaps
->VertexShaderVersion
= 0;
1271 pCaps
->MaxVertexShaderConst
= 0;
1274 if ((ps_mode
== PS_HW
) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM
) && (DeviceType
!= D3DDEVTYPE_REF
)) {
1275 pCaps
->PixelShaderVersion
= D3DPS_VERSION(1,4);
1276 pCaps
->MaxPixelShaderValue
= 1.0;
1278 pCaps
->PixelShaderVersion
= 0;
1279 pCaps
->MaxPixelShaderValue
= 0.0;
1282 /* ------------------------------------------------
1283 The following fields apply to d3d9 only
1284 ------------------------------------------------ */
1285 if (This
->dxVersion
> 8) {
1286 FIXME("Caps support for directx9 is non-existant at the moment!\n");
1287 pCaps
->DevCaps2
= 0;
1288 pCaps
->MaxNpatchTessellationLevel
= 0;
1289 pCaps
->MasterAdapterOrdinal
= 0;
1290 pCaps
->AdapterOrdinalInGroup
= 0;
1291 pCaps
->NumberOfAdaptersInGroup
= 1;
1292 pCaps
->DeclTypes
= 0;
1293 pCaps
->NumSimultaneousRTs
= 0;
1294 pCaps
->StretchRectFilterCaps
= 0;
1295 pCaps
->VS20Caps
.Caps
= 0;
1296 pCaps
->PS20Caps
.Caps
= 0;
1297 pCaps
->VertexTextureFilterCaps
= 0;
1298 pCaps
->MaxVShaderInstructionsExecuted
= 0;
1299 pCaps
->MaxPShaderInstructionsExecuted
= 0;
1300 pCaps
->MaxVertexShader30InstructionSlots
= 0;
1301 pCaps
->MaxPixelShader30InstructionSlots
= 0;
1304 /* If we created a dummy context, throw it away */
1305 if (NULL
!= fake_ctx
) WineD3D_ReleaseFakeGLContext(fake_ctx
);
1309 /**********************************************************
1310 * IUnknown parts follows
1311 **********************************************************/
1313 HRESULT WINAPI
IWineD3DImpl_QueryInterface(IWineD3D
*iface
,REFIID riid
,LPVOID
*ppobj
)
1315 return E_NOINTERFACE
;
1318 ULONG WINAPI
IWineD3DImpl_AddRef(IWineD3D
*iface
) {
1319 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
1320 FIXME("(%p) : AddRef increasing from %ld\n", This
, This
->ref
);
1321 return InterlockedIncrement(&This
->ref
);
1324 ULONG WINAPI
IWineD3DImpl_Release(IWineD3D
*iface
) {
1325 IWineD3DImpl
*This
= (IWineD3DImpl
*)iface
;
1327 TRACE("(%p) : Releasing from %ld\n", This
, This
->ref
);
1328 ref
= InterlockedDecrement(&This
->ref
);
1329 if (ref
== 0) HeapFree(GetProcessHeap(), 0, This
);
1333 /**********************************************************
1334 * IWineD3D VTbl follows
1335 **********************************************************/
1337 IWineD3DVtbl IWineD3D_Vtbl
=
1339 IWineD3DImpl_QueryInterface
,
1340 IWineD3DImpl_AddRef
,
1341 IWineD3DImpl_Release
,
1342 IWineD3DImpl_GetAdapterCount
,
1343 IWineD3DImpl_RegisterSoftwareDevice
,
1344 IWineD3DImpl_GetAdapterMonitor
,
1345 IWineD3DImpl_GetAdapterModeCount
,
1346 IWineD3DImpl_EnumAdapterModes
,
1347 IWineD3DImpl_GetAdapterDisplayMode
,
1348 IWineD3DImpl_GetAdapterIdentifier
,
1349 IWineD3DImpl_CheckDeviceMultiSampleType
,
1350 IWineD3DImpl_CheckDepthStencilMatch
,
1351 IWineD3DImpl_CheckDeviceType
,
1352 IWineD3DImpl_CheckDeviceFormat
,
1353 IWineD3DImpl_CheckDeviceFormatConversion
,
1354 IWineD3DImpl_GetDeviceCaps