2004-09-23 06:34:27 +02:00
/*
* IWineD3D implementation
*
* Copyright 2002 - 2004 Jason Edmeades
* Copyright 2003 - 2004 Raphael Junqueira
* Copyright 2004 Christian Costa
2005-06-23 13:05:24 +02:00
* Copyright 2005 Oliver Stieber
2008-10-18 19:21:20 +02:00
* Copyright 2007 - 2008 Stefan Dösinger for CodeWeavers
2004-09-23 06:34:27 +02:00
*
* This library is free software ; you can redistribute it and / or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation ; either
* version 2.1 of the License , or ( at your option ) any later version .
*
* This library is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* Lesser General Public License for more details .
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library ; if not , write to the Free Software
2006-05-18 14:49:52 +02:00
* Foundation , Inc . , 51 Franklin St , Fifth Floor , Boston , MA 02110 - 1301 , USA
2004-09-23 06:34:27 +02:00
*/
2004-09-28 04:12:12 +02:00
/* Compile time diagnostics: */
2007-02-23 09:27:42 +01:00
# ifndef DEBUG_SINGLE_MODE
/* Set to 1 to force only a single display mode to be exposed: */
# define DEBUG_SINGLE_MODE 0
# endif
2004-09-28 04:12:12 +02:00
2004-09-23 06:34:27 +02:00
# include "config.h"
2006-11-23 19:58:41 +01:00
# include <assert.h>
2004-09-23 06:34:27 +02:00
# include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL ( d3d ) ;
WINE_DECLARE_DEBUG_CHANNEL ( d3d_caps ) ;
2009-03-11 10:15:09 +01:00
# define GLINFO_LOCATION (*gl_info)
2008-03-13 15:14:00 +01:00
/* The d3d device ID */
static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4 , 0x6e41 , 0x43ea , { 0x94 , 0x1c , 0x83 , 0x61 , 0xcc , 0x76 , 0x07 , 0x81 } } ;
2007-06-26 23:05:41 +02:00
/* Extension detection */
static const struct {
const char * extension_string ;
GL_SupportedExt extension ;
2007-11-11 13:59:49 +01:00
DWORD version ;
2007-06-26 23:05:41 +02:00
} EXTENSION_MAP [ ] = {
/* APPLE */
2007-11-11 13:59:49 +01:00
{ " GL_APPLE_client_storage " , APPLE_CLIENT_STORAGE , 0 } ,
{ " GL_APPLE_fence " , APPLE_FENCE , 0 } ,
{ " GL_APPLE_flush_render " , APPLE_FLUSH_RENDER , 0 } ,
{ " GL_APPLE_ycbcr_422 " , APPLE_YCBCR_422 , 0 } ,
2008-02-13 14:22:40 +01:00
{ " GL_APPLE_float_pixels " , APPLE_FLOAT_PIXELS , 0 } ,
2007-06-26 23:05:41 +02:00
/* ATI */
2007-11-11 13:59:49 +01:00
{ " GL_ATI_separate_stencil " , ATI_SEPARATE_STENCIL , 0 } ,
{ " GL_ATI_texture_env_combine3 " , ATI_TEXTURE_ENV_COMBINE3 , 0 } ,
{ " GL_ATI_texture_mirror_once " , ATI_TEXTURE_MIRROR_ONCE , 0 } ,
2008-03-18 19:57:52 +01:00
{ " GL_ATI_fragment_shader " , ATI_FRAGMENT_SHADER , 0 } ,
2008-07-23 17:33:10 +02:00
{ " GL_ATI_texture_compression_3dc " , ATI_TEXTURE_COMPRESSION_3DC , 0 } ,
2007-06-26 23:05:41 +02:00
/* ARB */
2008-06-19 00:36:28 +02:00
{ " GL_ARB_color_buffer_float " , ARB_COLOR_BUFFER_FLOAT , 0 } ,
2007-11-11 13:59:49 +01:00
{ " GL_ARB_draw_buffers " , ARB_DRAW_BUFFERS , 0 } ,
{ " GL_ARB_fragment_program " , ARB_FRAGMENT_PROGRAM , 0 } ,
{ " GL_ARB_fragment_shader " , ARB_FRAGMENT_SHADER , 0 } ,
2009-03-05 12:30:43 +01:00
{ " GL_ARB_geometry_shader4 " , ARB_GEOMETRY_SHADER4 , 0 } ,
2007-11-11 13:59:49 +01:00
{ " GL_ARB_half_float_pixel " , ARB_HALF_FLOAT_PIXEL , 0 } ,
{ " GL_ARB_imaging " , ARB_IMAGING , 0 } ,
{ " GL_ARB_multisample " , ARB_MULTISAMPLE , 0 } , /* needs GLX_ARB_MULTISAMPLE as well */
{ " GL_ARB_multitexture " , ARB_MULTITEXTURE , 0 } ,
{ " GL_ARB_occlusion_query " , ARB_OCCLUSION_QUERY , 0 } ,
{ " GL_ARB_pixel_buffer_object " , ARB_PIXEL_BUFFER_OBJECT , 0 } ,
{ " GL_ARB_point_parameters " , ARB_POINT_PARAMETERS , 0 } ,
{ " GL_ARB_point_sprite " , ARB_POINT_SPRITE , 0 } ,
{ " GL_ARB_texture_border_clamp " , ARB_TEXTURE_BORDER_CLAMP , 0 } ,
{ " GL_ARB_texture_compression " , ARB_TEXTURE_COMPRESSION , 0 } ,
{ " GL_ARB_texture_cube_map " , ARB_TEXTURE_CUBE_MAP , 0 } ,
{ " GL_ARB_texture_env_add " , ARB_TEXTURE_ENV_ADD , 0 } ,
{ " GL_ARB_texture_env_combine " , ARB_TEXTURE_ENV_COMBINE , 0 } ,
{ " GL_ARB_texture_env_dot3 " , ARB_TEXTURE_ENV_DOT3 , 0 } ,
{ " GL_ARB_texture_float " , ARB_TEXTURE_FLOAT , 0 } ,
{ " GL_ARB_texture_mirrored_repeat " , ARB_TEXTURE_MIRRORED_REPEAT , 0 } ,
2008-07-09 01:59:10 +02:00
{ " GL_ARB_texture_non_power_of_two " , ARB_TEXTURE_NON_POWER_OF_TWO , MAKEDWORD_VERSION ( 2 , 0 ) } ,
2007-11-26 23:19:03 +01:00
{ " GL_ARB_texture_rectangle " , ARB_TEXTURE_RECTANGLE , 0 } ,
2008-12-17 23:20:02 +01:00
{ " GL_ARB_texture_rg " , ARB_TEXTURE_RG , 0 } ,
2007-11-11 13:59:49 +01:00
{ " GL_ARB_vertex_blend " , ARB_VERTEX_BLEND , 0 } ,
{ " GL_ARB_vertex_buffer_object " , ARB_VERTEX_BUFFER_OBJECT , 0 } ,
{ " GL_ARB_vertex_program " , ARB_VERTEX_PROGRAM , 0 } ,
{ " GL_ARB_vertex_shader " , ARB_VERTEX_SHADER , 0 } ,
{ " GL_ARB_shader_objects " , ARB_SHADER_OBJECTS , 0 } ,
2007-06-26 23:05:41 +02:00
/* EXT */
2008-01-13 00:32:24 +01:00
{ " GL_EXT_blend_color " , EXT_BLEND_COLOR , 0 } ,
2007-11-11 13:59:49 +01:00
{ " GL_EXT_blend_minmax " , EXT_BLEND_MINMAX , 0 } ,
2008-02-16 16:42:11 +01:00
{ " GL_EXT_blend_equation_separate " , EXT_BLEND_EQUATION_SEPARATE , 0 } ,
{ " GL_EXT_blend_func_separate " , EXT_BLEND_FUNC_SEPARATE , 0 } ,
2007-11-11 13:59:49 +01:00
{ " GL_EXT_fog_coord " , EXT_FOG_COORD , 0 } ,
{ " GL_EXT_framebuffer_blit " , EXT_FRAMEBUFFER_BLIT , 0 } ,
2008-10-20 00:15:13 +02:00
{ " GL_EXT_framebuffer_multisample " , EXT_FRAMEBUFFER_MULTISAMPLE , 0 } ,
2007-11-11 13:59:49 +01:00
{ " GL_EXT_framebuffer_object " , EXT_FRAMEBUFFER_OBJECT , 0 } ,
{ " GL_EXT_paletted_texture " , EXT_PALETTED_TEXTURE , 0 } ,
{ " GL_EXT_point_parameters " , EXT_POINT_PARAMETERS , 0 } ,
{ " GL_EXT_secondary_color " , EXT_SECONDARY_COLOR , 0 } ,
{ " GL_EXT_stencil_two_side " , EXT_STENCIL_TWO_SIDE , 0 } ,
{ " GL_EXT_stencil_wrap " , EXT_STENCIL_WRAP , 0 } ,
2007-11-06 13:07:33 +01:00
{ " GL_EXT_texture3D " , EXT_TEXTURE3D , MAKEDWORD_VERSION ( 1 , 2 ) } ,
2007-11-11 13:59:49 +01:00
{ " GL_EXT_texture_compression_s3tc " , EXT_TEXTURE_COMPRESSION_S3TC , 0 } ,
2008-07-23 17:39:04 +02:00
{ " GL_EXT_texture_compression_rgtc " , EXT_TEXTURE_COMPRESSION_RGTC , 0 } ,
2007-11-11 13:59:49 +01:00
{ " GL_EXT_texture_env_add " , EXT_TEXTURE_ENV_ADD , 0 } ,
{ " GL_EXT_texture_env_combine " , EXT_TEXTURE_ENV_COMBINE , 0 } ,
{ " GL_EXT_texture_env_dot3 " , EXT_TEXTURE_ENV_DOT3 , 0 } ,
{ " GL_EXT_texture_sRGB " , EXT_TEXTURE_SRGB , 0 } ,
2008-12-17 23:20:02 +01:00
{ " GL_EXT_texture_swizzle " , EXT_TEXTURE_SWIZZLE , 0 } ,
2007-11-11 13:59:49 +01:00
{ " GL_EXT_texture_filter_anisotropic " , EXT_TEXTURE_FILTER_ANISOTROPIC , 0 } ,
{ " GL_EXT_texture_lod " , EXT_TEXTURE_LOD , 0 } ,
{ " GL_EXT_texture_lod_bias " , EXT_TEXTURE_LOD_BIAS , 0 } ,
2009-01-08 10:19:17 +01:00
{ " GL_EXT_vertex_array_bgra " , EXT_VERTEX_ARRAY_BGRA , 0 } ,
2007-11-11 13:59:49 +01:00
{ " GL_EXT_vertex_shader " , EXT_VERTEX_SHADER , 0 } ,
2008-02-14 15:30:29 +01:00
{ " GL_EXT_gpu_program_parameters " , EXT_GPU_PROGRAM_PARAMETERS , 0 } ,
2007-06-26 23:05:41 +02:00
/* NV */
2007-11-11 13:59:49 +01:00
{ " GL_NV_half_float " , NV_HALF_FLOAT , 0 } ,
{ " GL_NV_fence " , NV_FENCE , 0 } ,
{ " GL_NV_fog_distance " , NV_FOG_DISTANCE , 0 } ,
{ " GL_NV_fragment_program " , NV_FRAGMENT_PROGRAM , 0 } ,
{ " GL_NV_fragment_program2 " , NV_FRAGMENT_PROGRAM2 , 0 } ,
{ " GL_NV_register_combiners " , NV_REGISTER_COMBINERS , 0 } ,
{ " GL_NV_register_combiners2 " , NV_REGISTER_COMBINERS2 , 0 } ,
{ " GL_NV_texgen_reflection " , NV_TEXGEN_REFLECTION , 0 } ,
{ " GL_NV_texture_env_combine4 " , NV_TEXTURE_ENV_COMBINE4 , 0 } ,
{ " GL_NV_texture_shader " , NV_TEXTURE_SHADER , 0 } ,
{ " GL_NV_texture_shader2 " , NV_TEXTURE_SHADER2 , 0 } ,
{ " GL_NV_texture_shader3 " , NV_TEXTURE_SHADER3 , 0 } ,
{ " GL_NV_occlusion_query " , NV_OCCLUSION_QUERY , 0 } ,
{ " GL_NV_vertex_program " , NV_VERTEX_PROGRAM , 0 } ,
{ " GL_NV_vertex_program1_1 " , NV_VERTEX_PROGRAM1_1 , 0 } ,
{ " GL_NV_vertex_program2 " , NV_VERTEX_PROGRAM2 , 0 } ,
{ " GL_NV_vertex_program3 " , NV_VERTEX_PROGRAM3 , 0 } ,
{ " GL_NV_depth_clamp " , NV_DEPTH_CLAMP , 0 } ,
2008-03-02 00:02:18 +01:00
{ " GL_NV_light_max_exponent " , NV_LIGHT_MAX_EXPONENT , 0 } ,
2007-08-31 20:56:15 +02:00
/* SGI */
2007-11-11 13:59:49 +01:00
{ " GL_SGIS_generate_mipmap " , SGIS_GENERATE_MIPMAP , 0 } ,
2007-06-26 23:05:41 +02:00
} ;
2004-09-29 23:26:47 +02:00
/**********************************************************
* Utility functions follow
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-08-27 17:42:40 +02:00
static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat ( IWineD3D * iface , UINT Adapter , WINED3DDEVTYPE DeviceType , WINED3DFORMAT AdapterFormat , DWORD Usage , WINED3DRESOURCETYPE RType , WINED3DFORMAT CheckFormat , WINED3DSURFTYPE SurfaceType ) ;
2009-03-11 10:15:09 +01:00
static const struct fragment_pipeline * select_fragment_implementation ( struct WineD3DAdapter * adapter ,
WINED3DDEVTYPE DeviceType ) ;
static const shader_backend_t * select_shader_backend ( struct WineD3DAdapter * adapter , WINED3DDEVTYPE DeviceType ) ;
static const struct blit_shader * select_blit_implementation ( struct WineD3DAdapter * adapter , WINED3DDEVTYPE DeviceType ) ;
2008-02-26 10:47:30 +01:00
2005-08-03 13:00:28 +02:00
/* lookup tables */
2008-11-28 15:30:11 +01:00
const int minLookup [ MAX_LOOKUPS ] =
{
WINED3DTADDRESS_WRAP , /* WINELOOKUP_WARPPARAM */
} ;
const int maxLookup [ MAX_LOOKUPS ] =
{
WINED3DTADDRESS_MIRRORONCE , /* WINELOOKUP_WARPPARAM */
} ;
2005-08-03 13:00:28 +02:00
DWORD * stateLookup [ MAX_LOOKUPS ] ;
2008-11-26 16:14:40 +01:00
struct min_lookup minMipLookup [ WINED3DTEXF_ANISOTROPIC + 1 ] ;
const struct min_lookup minMipLookup_noFilter [ WINED3DTEXF_ANISOTROPIC + 1 ] =
{
{ { GL_NEAREST , GL_NEAREST , GL_NEAREST } } ,
{ { GL_NEAREST , GL_NEAREST , GL_NEAREST } } ,
{ { GL_NEAREST , GL_NEAREST , GL_NEAREST } } ,
{ { GL_NEAREST , GL_NEAREST , GL_NEAREST } } ,
2008-04-06 00:22:08 +02:00
} ;
2005-08-03 13:00:28 +02:00
2008-11-26 16:14:40 +01:00
GLenum magLookup [ WINED3DTEXF_ANISOTROPIC + 1 ] ;
const GLenum magLookup_noFilter [ WINED3DTEXF_ANISOTROPIC + 1 ] =
{
2008-04-06 00:37:51 +02:00
GL_NEAREST , GL_NEAREST , GL_NEAREST , GL_NEAREST
} ;
2008-04-06 00:31:39 +02:00
2007-12-19 17:10:02 +01:00
/* drawStridedSlow attributes */
2009-03-27 10:25:56 +01:00
glAttribFunc position_funcs [ WINED3D_FFP_EMIT_COUNT ] ;
glAttribFunc diffuse_funcs [ WINED3D_FFP_EMIT_COUNT ] ;
2009-03-11 10:15:09 +01:00
glAttribFunc specular_func_3ubv ;
2009-03-27 10:25:56 +01:00
glAttribFunc specular_funcs [ WINED3D_FFP_EMIT_COUNT ] ;
glAttribFunc normal_funcs [ WINED3D_FFP_EMIT_COUNT ] ;
glMultiTexCoordFunc multi_texcoord_funcs [ WINED3D_FFP_EMIT_COUNT ] ;
2005-08-03 13:00:28 +02:00
2004-09-29 23:26:47 +02:00
/**
2008-04-23 07:13:32 +02:00
* Note : GL seems to trap if GetDeviceCaps is called before any HWND ' s created ,
* i . e . , there is no GL Context - Get a default rendering context to enable the
* function query some info from GL .
2005-07-13 16:15:54 +02:00
*/
2006-11-23 19:58:41 +01:00
static int wined3d_fake_gl_context_ref = 0 ;
static BOOL wined3d_fake_gl_context_foreign ;
static BOOL wined3d_fake_gl_context_available = FALSE ;
2007-08-07 23:45:00 +02:00
static HDC wined3d_fake_gl_context_hdc = NULL ;
static HWND wined3d_fake_gl_context_hwnd = NULL ;
2006-11-23 19:58:41 +01:00
2007-02-23 09:24:45 +01:00
static CRITICAL_SECTION wined3d_fake_gl_context_cs ;
static CRITICAL_SECTION_DEBUG wined3d_fake_gl_context_cs_debug =
{
0 , 0 , & wined3d_fake_gl_context_cs ,
{ & wined3d_fake_gl_context_cs_debug . ProcessLocksList ,
& wined3d_fake_gl_context_cs_debug . ProcessLocksList } ,
0 , 0 , { ( DWORD_PTR ) ( __FILE__ " : wined3d_fake_gl_context_cs " ) }
} ;
static CRITICAL_SECTION wined3d_fake_gl_context_cs = { & wined3d_fake_gl_context_cs_debug , - 1 , 0 , 0 , 0 , 0 } ;
2006-11-23 19:58:41 +01:00
static void WineD3D_ReleaseFakeGLContext ( void ) {
2007-08-07 23:45:00 +02:00
HGLRC glCtx ;
2006-11-23 19:58:41 +01:00
2007-02-23 09:24:45 +01:00
EnterCriticalSection ( & wined3d_fake_gl_context_cs ) ;
2006-11-23 19:58:41 +01:00
if ( ! wined3d_fake_gl_context_available ) {
TRACE_ ( d3d_caps ) ( " context not available \n " ) ;
2007-02-23 09:24:45 +01:00
LeaveCriticalSection ( & wined3d_fake_gl_context_cs ) ;
2006-11-23 19:58:41 +01:00
return ;
}
2007-08-16 15:04:47 +02:00
glCtx = pwglGetCurrentContext ( ) ;
2006-11-23 19:58:41 +01:00
TRACE_ ( d3d_caps ) ( " decrementing ref from %i \n " , wined3d_fake_gl_context_ref ) ;
if ( 0 = = ( - - wined3d_fake_gl_context_ref ) ) {
if ( ! wined3d_fake_gl_context_foreign & & glCtx ) {
TRACE_ ( d3d_caps ) ( " destroying fake GL context \n " ) ;
2007-08-16 15:04:47 +02:00
pwglMakeCurrent ( NULL , NULL ) ;
pwglDeleteContext ( glCtx ) ;
2006-11-23 19:58:41 +01:00
}
2007-08-07 23:45:00 +02:00
if ( wined3d_fake_gl_context_hdc )
ReleaseDC ( wined3d_fake_gl_context_hwnd , wined3d_fake_gl_context_hdc ) ;
wined3d_fake_gl_context_hdc = NULL ; /* Make sure we don't think that it is still around */
if ( wined3d_fake_gl_context_hwnd )
DestroyWindow ( wined3d_fake_gl_context_hwnd ) ;
wined3d_fake_gl_context_hwnd = NULL ;
2006-11-23 19:58:41 +01:00
wined3d_fake_gl_context_available = FALSE ;
}
assert ( wined3d_fake_gl_context_ref > = 0 ) ;
2007-02-23 09:24:45 +01:00
LeaveCriticalSection ( & wined3d_fake_gl_context_cs ) ;
2004-09-29 23:26:47 +02:00
}
2006-11-23 19:58:41 +01:00
static BOOL WineD3D_CreateFakeGLContext ( void ) {
2007-08-08 03:09:38 +02:00
HGLRC glCtx = NULL ;
2006-11-23 19:58:41 +01:00
2007-02-23 09:24:45 +01:00
EnterCriticalSection ( & wined3d_fake_gl_context_cs ) ;
2007-08-07 23:45:00 +02:00
TRACE ( " getting context... \n " ) ;
2006-11-23 19:58:41 +01:00
if ( wined3d_fake_gl_context_ref > 0 ) goto ret ;
assert ( 0 = = wined3d_fake_gl_context_ref ) ;
wined3d_fake_gl_context_foreign = TRUE ;
2007-08-16 15:04:47 +02:00
glCtx = pwglGetCurrentContext ( ) ;
2006-11-23 19:58:41 +01:00
if ( ! glCtx ) {
2007-08-07 23:45:00 +02:00
PIXELFORMATDESCRIPTOR pfd ;
int iPixelFormat ;
2006-11-23 19:58:41 +01:00
wined3d_fake_gl_context_foreign = FALSE ;
2007-08-07 23:45:00 +02:00
/* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes */
wined3d_fake_gl_context_hwnd = CreateWindowA ( " WineD3D_OpenGL " , " WineD3D fake window " , WS_OVERLAPPEDWINDOW , 10 , 10 , 10 , 10 , NULL , NULL , NULL , NULL ) ;
if ( ! wined3d_fake_gl_context_hwnd ) {
ERR ( " HWND creation failed! \n " ) ;
goto fail ;
}
wined3d_fake_gl_context_hdc = GetDC ( wined3d_fake_gl_context_hwnd ) ;
if ( ! wined3d_fake_gl_context_hdc ) {
ERR ( " GetDC failed! \n " ) ;
goto fail ;
2006-11-23 19:58:41 +01:00
}
2007-08-07 23:45:00 +02:00
/* PixelFormat selection */
ZeroMemory ( & pfd , sizeof ( pfd ) ) ;
pfd . nSize = sizeof ( pfd ) ;
pfd . nVersion = 1 ;
pfd . dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW ; /*PFD_GENERIC_ACCELERATED*/
pfd . iPixelType = PFD_TYPE_RGBA ;
pfd . cColorBits = 32 ;
pfd . iLayerType = PFD_MAIN_PLANE ;
iPixelFormat = ChoosePixelFormat ( wined3d_fake_gl_context_hdc , & pfd ) ;
if ( ! iPixelFormat ) {
/* If this happens something is very wrong as ChoosePixelFormat barely fails */
ERR ( " Can't find a suitable iPixelFormat \n " ) ;
2006-11-23 19:58:41 +01:00
goto fail ;
}
2007-08-07 23:45:00 +02:00
DescribePixelFormat ( wined3d_fake_gl_context_hdc , iPixelFormat , sizeof ( pfd ) , & pfd ) ;
SetPixelFormat ( wined3d_fake_gl_context_hdc , iPixelFormat , & pfd ) ;
2006-11-23 19:58:41 +01:00
/* Create a GL context */
2007-08-16 15:04:47 +02:00
glCtx = pwglCreateContext ( wined3d_fake_gl_context_hdc ) ;
2007-08-08 03:09:38 +02:00
if ( ! glCtx ) {
2006-11-23 19:58:41 +01:00
WARN_ ( d3d_caps ) ( " Error creating default context for capabilities initialization \n " ) ;
goto fail ;
2004-09-29 23:26:47 +02:00
}
2006-11-23 19:58:41 +01:00
/* Make it the current GL context */
2007-08-16 15:04:47 +02:00
if ( ! pwglMakeCurrent ( wined3d_fake_gl_context_hdc , glCtx ) ) {
2006-11-23 19:58:41 +01:00
WARN_ ( d3d_caps ) ( " Error setting default context as current for capabilities initialization \n " ) ;
goto fail ;
}
2004-09-29 23:26:47 +02:00
}
2006-11-23 19:58:41 +01:00
ret :
2007-08-07 23:45:00 +02:00
TRACE ( " incrementing ref from %i \n " , wined3d_fake_gl_context_ref ) ;
2006-11-23 19:58:41 +01:00
wined3d_fake_gl_context_ref + + ;
wined3d_fake_gl_context_available = TRUE ;
2007-02-23 09:24:45 +01:00
LeaveCriticalSection ( & wined3d_fake_gl_context_cs ) ;
2006-11-23 19:58:41 +01:00
return TRUE ;
fail :
2007-08-07 23:45:00 +02:00
if ( wined3d_fake_gl_context_hdc )
ReleaseDC ( wined3d_fake_gl_context_hwnd , wined3d_fake_gl_context_hdc ) ;
wined3d_fake_gl_context_hdc = NULL ;
if ( wined3d_fake_gl_context_hwnd )
DestroyWindow ( wined3d_fake_gl_context_hwnd ) ;
wined3d_fake_gl_context_hwnd = NULL ;
2007-08-16 15:04:47 +02:00
if ( glCtx ) pwglDeleteContext ( glCtx ) ;
2007-02-23 09:24:45 +01:00
LeaveCriticalSection ( & wined3d_fake_gl_context_cs ) ;
2006-11-23 19:58:41 +01:00
return FALSE ;
2004-09-29 23:26:47 +02:00
}
2007-09-23 00:46:21 +02:00
/* Adjust the amount of used texture memory */
long WineD3DAdapterChangeGLRam ( IWineD3DDeviceImpl * D3DDevice , long glram ) {
2009-03-11 10:15:09 +01:00
struct WineD3DAdapter * adapter = D3DDevice - > adapter ;
2007-09-23 00:46:21 +02:00
2009-03-11 10:15:09 +01:00
adapter - > UsedTextureRam + = glram ;
TRACE ( " Adjusted gl ram by %ld to %d \n " , glram , adapter - > UsedTextureRam ) ;
return adapter - > UsedTextureRam ;
2007-09-23 00:46:21 +02:00
}
2007-08-07 23:45:00 +02:00
2005-03-02 14:44:58 +01:00
/**********************************************************
* IUnknown parts follows
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-06-10 13:15:32 +02:00
static HRESULT WINAPI IWineD3DImpl_QueryInterface ( IWineD3D * iface , REFIID riid , LPVOID * ppobj )
2005-03-02 14:44:58 +01:00
{
IWineD3DDeviceImpl * This = ( IWineD3DDeviceImpl * ) iface ;
2005-07-13 16:15:54 +02:00
2005-03-02 14:44:58 +01:00
TRACE ( " (%p)->(%s,%p) \n " , This , debugstr_guid ( riid ) , ppobj ) ;
2005-07-13 16:15:54 +02:00
if ( IsEqualGUID ( riid , & IID_IUnknown )
2006-02-06 11:32:41 +01:00
| | IsEqualGUID ( riid , & IID_IWineD3DBase )
2005-03-02 14:44:58 +01:00
| | IsEqualGUID ( riid , & IID_IWineD3DDevice ) ) {
IUnknown_AddRef ( iface ) ;
* ppobj = This ;
2006-04-25 23:59:12 +02:00
return S_OK ;
2005-03-02 14:44:58 +01:00
}
2006-04-25 23:59:12 +02:00
* ppobj = NULL ;
2005-03-02 14:44:58 +01:00
return E_NOINTERFACE ;
}
2006-06-10 13:15:32 +02:00
static ULONG WINAPI IWineD3DImpl_AddRef ( IWineD3D * iface ) {
2005-03-02 14:44:58 +01:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
ULONG refCount = InterlockedIncrement ( & This - > ref ) ;
2006-10-01 05:20:10 +02:00
TRACE ( " (%p) : AddRef increasing from %d \n " , This , refCount - 1 ) ;
2005-03-02 14:44:58 +01:00
return refCount ;
}
2006-06-10 13:15:32 +02:00
static ULONG WINAPI IWineD3DImpl_Release ( IWineD3D * iface ) {
2005-03-02 14:44:58 +01:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
ULONG ref ;
2006-10-01 05:20:10 +02:00
TRACE ( " (%p) : Releasing from %d \n " , This , This - > ref ) ;
2005-03-02 14:44:58 +01:00
ref = InterlockedDecrement ( & This - > ref ) ;
if ( ref = = 0 ) {
2009-03-11 10:15:10 +01:00
unsigned int i ;
for ( i = 0 ; i < This - > adapter_count ; + + i )
{
HeapFree ( GetProcessHeap ( ) , 0 , This - > adapters [ i ] . cfgs ) ;
}
2005-03-02 14:44:58 +01:00
HeapFree ( GetProcessHeap ( ) , 0 , This ) ;
}
2005-07-13 16:15:54 +02:00
2005-03-02 14:44:58 +01:00
return ref ;
}
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
/* Set the shader type for this device, depending on the given capabilities,
* the device type , and the user preferences in wined3d_settings */
2008-12-02 15:31:17 +01:00
static void select_shader_mode ( const WineD3D_GL_Info * gl_info , WINED3DDEVTYPE DeviceType , int * ps_selected , int * vs_selected )
2008-11-28 15:30:11 +01:00
{
2006-07-19 06:06:07 +02:00
if ( wined3d_settings . vs_mode = = VS_NONE ) {
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
* vs_selected = SHADER_NONE ;
2006-07-30 23:28:10 +02:00
} else if ( gl_info - > supported [ ARB_VERTEX_SHADER ] & & wined3d_settings . glslRequested ) {
2007-10-28 00:28:53 +02:00
/* Geforce4 cards support GLSL but for vertex shaders only. Further its reported GLSL caps are
* wrong . This combined with the fact that glsl won ' t offer more features or performance , use ARB
* shaders only on this card . */
2007-11-03 01:04:36 +01:00
if ( gl_info - > vs_nv_version & & gl_info - > vs_nv_version < VS_VERSION_20 )
2007-10-28 00:28:53 +02:00
* vs_selected = SHADER_ARB ;
else
* vs_selected = SHADER_GLSL ;
2006-07-19 06:06:07 +02:00
} else if ( gl_info - > supported [ ARB_VERTEX_PROGRAM ] ) {
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
* vs_selected = SHADER_ARB ;
2006-07-19 06:06:07 +02:00
} else {
2007-03-06 22:35:23 +01:00
* vs_selected = SHADER_NONE ;
2006-07-19 06:06:07 +02:00
}
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
2006-07-19 06:06:07 +02:00
if ( wined3d_settings . ps_mode = = PS_NONE ) {
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
* ps_selected = SHADER_NONE ;
2006-07-30 23:28:10 +02:00
} else if ( gl_info - > supported [ ARB_FRAGMENT_SHADER ] & & wined3d_settings . glslRequested ) {
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
* ps_selected = SHADER_GLSL ;
2006-07-19 06:06:07 +02:00
} else if ( gl_info - > supported [ ARB_FRAGMENT_PROGRAM ] ) {
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
* ps_selected = SHADER_ARB ;
2008-03-22 14:31:52 +01:00
} else if ( gl_info - > supported [ ATI_FRAGMENT_SHADER ] ) {
* ps_selected = SHADER_ATI ;
2006-07-19 06:06:07 +02:00
} else {
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
* ps_selected = SHADER_NONE ;
2006-07-19 06:06:07 +02:00
}
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
}
2006-07-23 21:08:27 +02:00
/** Select the number of report maximum shader constants based on the selected shader modes */
2007-03-12 16:50:54 +01:00
static void select_shader_max_constants (
2006-10-08 05:25:01 +02:00
int ps_selected_mode ,
int vs_selected_mode ,
WineD3D_GL_Info * gl_info ) {
2006-07-23 21:08:27 +02:00
2006-10-08 05:25:01 +02:00
switch ( vs_selected_mode ) {
2006-07-23 21:08:27 +02:00
case SHADER_GLSL :
2006-07-28 10:14:14 +02:00
/* Subtract the other potential uniforms from the max available (bools, ints, and 1 row of projection matrix) */
2007-02-27 20:51:43 +01:00
gl_info - > max_vshader_constantsF = gl_info - > vs_glsl_constantsF - ( MAX_CONST_B / 4 ) - MAX_CONST_I - 1 ;
2006-07-23 21:08:27 +02:00
break ;
case SHADER_ARB :
2006-07-27 04:13:32 +02:00
/* We have to subtract any other PARAMs that we might use in our shader programs.
* ATI seems to count 2 implicit PARAMs when we use fog and NVIDIA counts 1 ,
* and we reference one row of the PROJECTION matrix which counts as 1 PARAM . */
gl_info - > max_vshader_constantsF = gl_info - > vs_arb_constantsF - 3 ;
2006-07-23 21:08:27 +02:00
break ;
default :
gl_info - > max_vshader_constantsF = 0 ;
break ;
}
2006-10-08 05:25:01 +02:00
switch ( ps_selected_mode ) {
2006-07-23 21:08:27 +02:00
case SHADER_GLSL :
2007-03-22 17:32:48 +01:00
/* Subtract the other potential uniforms from the max available (bools & ints), and 2 states for fog.
2007-02-15 03:05:17 +01:00
* In theory the texbem instruction may need one more shader constant too . But lets assume
* that a sm < = 1.3 shader does not need all the uniforms provided by a glsl - capable card ,
* and lets not take away a uniform needlessly from all other shaders .
*/
2007-03-22 17:32:48 +01:00
gl_info - > max_pshader_constantsF = gl_info - > ps_glsl_constantsF - ( MAX_CONST_B / 4 ) - MAX_CONST_I - 2 ;
2006-07-23 21:08:27 +02:00
break ;
case SHADER_ARB :
2007-02-15 03:05:17 +01:00
/* The arb shader only loads the bump mapping environment matrix into the shader if it finds
2007-03-22 17:32:48 +01:00
* a free constant to do that , so only reduce the number of available constants by 2 for the fog states .
2007-02-15 03:05:17 +01:00
*/
2007-03-22 17:32:48 +01:00
gl_info - > max_pshader_constantsF = gl_info - > ps_arb_constantsF - 2 ;
2006-07-23 21:08:27 +02:00
break ;
default :
gl_info - > max_pshader_constantsF = 0 ;
break ;
}
}
2005-03-02 14:44:58 +01:00
/**********************************************************
* IWineD3D parts follows
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-11-28 15:30:11 +01:00
static inline BOOL test_arb_vs_offset_limit ( const WineD3D_GL_Info * gl_info )
{
2007-11-07 19:57:49 +01:00
GLuint prog ;
BOOL ret = FALSE ;
const char * testcode =
" !!ARBvp1.0 \n "
" PARAM C[66] = { program.env[0..65] }; \n "
" ADDRESS A0; "
2008-02-11 01:53:53 +01:00
" PARAM zero = {0.0, 0.0, 0.0, 0.0}; \n "
" ARL A0.x, zero.x; \n "
2007-11-07 19:57:49 +01:00
" MOV result.position, C[A0.x + 65]; \n "
" END \n " ;
while ( glGetError ( ) ) ;
GL_EXTCALL ( glGenProgramsARB ( 1 , & prog ) ) ;
if ( ! prog ) {
ERR ( " Failed to create an ARB offset limit test program \n " ) ;
}
GL_EXTCALL ( glBindProgramARB ( GL_VERTEX_PROGRAM_ARB , prog ) ) ;
GL_EXTCALL ( glProgramStringARB ( GL_VERTEX_PROGRAM_ARB , GL_PROGRAM_FORMAT_ASCII_ARB ,
strlen ( testcode ) , testcode ) ) ;
if ( glGetError ( ) ! = 0 ) {
TRACE ( " OpenGL implementation does not allow indirect addressing offsets > 63 \n " ) ;
TRACE ( " error: %s \n " , debugstr_a ( ( const char * ) glGetString ( GL_PROGRAM_ERROR_STRING_ARB ) ) ) ;
ret = TRUE ;
} else TRACE ( " OpenGL implementation allows offsets > 63 \n " ) ;
GL_EXTCALL ( glBindProgramARB ( GL_VERTEX_PROGRAM_ARB , 0 ) ) ;
GL_EXTCALL ( glDeleteProgramsARB ( 1 , & prog ) ) ;
checkGLcall ( " ARB vp offset limit test cleanup \n " ) ;
return ret ;
}
2007-11-11 13:59:49 +01:00
static DWORD ver_for_ext ( GL_SupportedExt ext )
{
unsigned int i ;
for ( i = 0 ; i < ( sizeof ( EXTENSION_MAP ) / sizeof ( * EXTENSION_MAP ) ) ; + + i ) {
if ( EXTENSION_MAP [ i ] . extension = = ext ) {
return EXTENSION_MAP [ i ] . version ;
}
}
return 0 ;
}
2008-12-02 15:31:17 +01:00
static BOOL IWineD3DImpl_FillGLCaps ( WineD3D_GL_Info * gl_info ) {
2004-09-29 23:26:47 +02:00
const char * GL_Extensions = NULL ;
2007-08-08 03:09:38 +02:00
const char * WGL_Extensions = NULL ;
2004-09-29 23:26:47 +02:00
const char * gl_string = NULL ;
const char * gl_string_cursor = NULL ;
GLint gl_max ;
2006-08-06 13:53:19 +02:00
GLfloat gl_floatv [ 2 ] ;
2007-08-05 21:33:30 +02:00
int major = 1 , minor = 0 ;
2006-11-23 19:58:41 +01:00
BOOL return_value = TRUE ;
2007-12-01 02:53:10 +01:00
unsigned i ;
2007-08-08 03:09:38 +02:00
HDC hdc ;
2007-09-17 22:16:48 +02:00
unsigned int vidmem = 0 ;
2007-08-16 15:04:47 +02:00
TRACE_ ( d3d_caps ) ( " (%p) \n " , gl_info ) ;
2007-09-29 16:38:11 +02:00
ENTER_GL ( ) ;
2005-11-30 12:02:45 +01:00
gl_string = ( const char * ) glGetString ( GL_RENDERER ) ;
2009-01-09 10:23:43 +01:00
if ( ! gl_string ) gl_string = " None " ;
2005-11-30 12:02:45 +01:00
strcpy ( gl_info - > gl_renderer , gl_string ) ;
2006-01-19 11:55:34 +01:00
gl_string = ( const char * ) glGetString ( GL_VENDOR ) ;
2005-07-10 19:48:07 +02:00
TRACE_ ( d3d_caps ) ( " Filling vendor string %s \n " , gl_string ) ;
if ( gl_string ! = NULL ) {
/* Fill in the GL vendor */
if ( strstr ( gl_string , " NVIDIA " ) ) {
gl_info - > gl_vendor = VENDOR_NVIDIA ;
} else if ( strstr ( gl_string , " ATI " ) ) {
gl_info - > gl_vendor = VENDOR_ATI ;
2007-11-30 16:51:32 +01:00
} else if ( strstr ( gl_string , " Intel(R) " ) | |
strstr ( gl_info - > gl_renderer , " Intel(R) " ) | |
strstr ( gl_string , " Intel Inc. " ) ) {
2005-11-30 12:02:45 +01:00
gl_info - > gl_vendor = VENDOR_INTEL ;
2005-11-10 12:04:59 +01:00
} else if ( strstr ( gl_string , " Mesa " ) ) {
gl_info - > gl_vendor = VENDOR_MESA ;
2005-07-10 19:48:07 +02:00
} else {
gl_info - > gl_vendor = VENDOR_WINE ;
}
2004-09-29 23:26:47 +02:00
} else {
gl_info - > gl_vendor = VENDOR_WINE ;
}
2005-07-10 19:48:07 +02:00
2004-09-29 23:26:47 +02:00
TRACE_ ( d3d_caps ) ( " found GL_VENDOR (%s)->(0x%04x) \n " , debugstr_a ( gl_string ) , gl_info - > gl_vendor ) ;
2005-07-10 19:48:07 +02:00
2004-09-29 23:26:47 +02:00
/* Parse the GL_VERSION field into major and minor information */
2005-08-11 12:57:47 +02:00
gl_string = ( const char * ) glGetString ( GL_VERSION ) ;
2005-07-10 19:48:07 +02:00
if ( gl_string ! = NULL ) {
2008-02-05 22:49:14 +01:00
/* First, parse the generic opengl version. This is supposed not to be convoluted with
* driver specific information
*/
gl_string_cursor = gl_string ;
major = atoi ( gl_string_cursor ) ;
if ( major < = 0 ) {
ERR ( " Invalid opengl major version: %d \n " , major ) ;
}
while ( * gl_string_cursor < = ' 9 ' & & * gl_string_cursor > = ' 0 ' ) {
+ + gl_string_cursor ;
}
if ( * gl_string_cursor + + ! = ' . ' ) {
ERR_ ( d3d_caps ) ( " Invalid opengl version string: %s \n " , debugstr_a ( gl_string ) ) ;
}
minor = atoi ( gl_string_cursor ) ;
TRACE_ ( d3d_caps ) ( " Found OpenGL version: %d.%d \n " , major , minor ) ;
gl_info - > gl_version = MAKEDWORD_VERSION ( major , minor ) ;
/* Now parse the driver specific string which we'll report to the app */
2005-07-10 19:48:07 +02:00
switch ( gl_info - > gl_vendor ) {
case VENDOR_NVIDIA :
gl_string_cursor = strstr ( gl_string , " NVIDIA " ) ;
2006-01-19 12:39:37 +01:00
if ( ! gl_string_cursor ) {
ERR_ ( d3d_caps ) ( " Invalid nVidia version string: %s \n " , debugstr_a ( gl_string ) ) ;
break ;
}
2005-07-10 19:48:07 +02:00
gl_string_cursor = strstr ( gl_string_cursor , " " ) ;
2006-01-19 12:39:37 +01:00
if ( ! gl_string_cursor ) {
ERR_ ( d3d_caps ) ( " Invalid nVidia version string: %s \n " , debugstr_a ( gl_string ) ) ;
break ;
}
while ( * gl_string_cursor = = ' ' ) {
+ + gl_string_cursor ;
}
if ( ! * gl_string_cursor ) {
ERR_ ( d3d_caps ) ( " Invalid nVidia version string: %s \n " , debugstr_a ( gl_string ) ) ;
break ;
}
major = atoi ( gl_string_cursor ) ;
while ( * gl_string_cursor < = ' 9 ' & & * gl_string_cursor > = ' 0 ' ) {
2004-09-29 23:26:47 +02:00
+ + gl_string_cursor ;
2006-01-19 12:39:37 +01:00
}
2005-07-13 16:15:54 +02:00
2006-01-19 12:39:37 +01:00
if ( * gl_string_cursor + + ! = ' . ' ) {
ERR_ ( d3d_caps ) ( " Invalid nVidia version string: %s \n " , debugstr_a ( gl_string ) ) ;
break ;
2004-09-29 23:26:47 +02:00
}
2006-01-19 12:39:37 +01:00
minor = atoi ( gl_string_cursor ) ;
2006-02-11 12:16:29 +01:00
minor = major * 100 + minor ;
major = 10 ;
2006-01-19 12:39:37 +01:00
2005-07-10 19:48:07 +02:00
break ;
2005-07-13 16:15:54 +02:00
2005-07-10 19:48:07 +02:00
case VENDOR_ATI :
major = minor = 0 ;
gl_string_cursor = strchr ( gl_string , ' - ' ) ;
if ( gl_string_cursor ) {
int error = 0 ;
gl_string_cursor + + ;
2005-07-13 16:15:54 +02:00
2005-07-10 19:48:07 +02:00
/* Check if version number is of the form x.y.z */
if ( * gl_string_cursor > ' 9 ' & & * gl_string_cursor < ' 0 ' )
error = 1 ;
if ( ! error & & * ( gl_string_cursor + 2 ) > ' 9 ' & & * ( gl_string_cursor + 2 ) < ' 0 ' )
error = 1 ;
if ( ! error & & * ( gl_string_cursor + 4 ) > ' 9 ' & & * ( gl_string_cursor + 4 ) < ' 0 ' )
error = 1 ;
if ( ! error & & * ( gl_string_cursor + 1 ) ! = ' . ' & & * ( gl_string_cursor + 3 ) ! = ' . ' )
error = 1 ;
2005-07-13 16:15:54 +02:00
2005-07-10 19:48:07 +02:00
/* Mark version number as malformed */
if ( error )
gl_string_cursor = 0 ;
2004-09-29 23:26:47 +02:00
}
2005-07-13 16:15:54 +02:00
2005-07-10 19:48:07 +02:00
if ( ! gl_string_cursor )
WARN_ ( d3d_caps ) ( " malformed GL_VERSION (%s) \n " , debugstr_a ( gl_string ) ) ;
else {
major = * gl_string_cursor - ' 0 ' ;
minor = ( * ( gl_string_cursor + 2 ) - ' 0 ' ) * 256 + ( * ( gl_string_cursor + 4 ) - ' 0 ' ) ;
2005-07-13 16:15:54 +02:00
}
2005-07-10 19:48:07 +02:00
break ;
2005-07-13 16:15:54 +02:00
2007-11-30 16:51:32 +01:00
case VENDOR_INTEL :
/* Apple and Mesa version strings look differently, but both provide intel drivers */
if ( strstr ( gl_string , " APPLE " ) ) {
/* [0-9]+.[0-9]+ APPLE-[0-9]+.[0.9]+.[0.9]+
* We only need the first part , and use the APPLE as identification
* " 1.2 APPLE-1.4.56 "
*/
gl_string_cursor = gl_string ;
major = atoi ( gl_string_cursor ) ;
while ( * gl_string_cursor < = ' 9 ' & & * gl_string_cursor > = ' 0 ' ) {
+ + gl_string_cursor ;
}
if ( * gl_string_cursor + + ! = ' . ' ) {
ERR_ ( d3d_caps ) ( " Invalid MacOS-Intel version string: %s \n " , debugstr_a ( gl_string ) ) ;
break ;
}
minor = atoi ( gl_string_cursor ) ;
break ;
}
2005-11-10 12:04:59 +01:00
case VENDOR_MESA :
gl_string_cursor = strstr ( gl_string , " Mesa " ) ;
gl_string_cursor = strstr ( gl_string_cursor , " " ) ;
while ( * gl_string_cursor & & ' ' = = * gl_string_cursor ) + + gl_string_cursor ;
if ( * gl_string_cursor ) {
char tmp [ 16 ] ;
int cursor = 0 ;
while ( * gl_string_cursor < = ' 9 ' & & * gl_string_cursor > = ' 0 ' ) {
tmp [ cursor + + ] = * gl_string_cursor ;
+ + gl_string_cursor ;
}
tmp [ cursor ] = 0 ;
major = atoi ( tmp ) ;
if ( * gl_string_cursor ! = ' . ' ) WARN_ ( d3d_caps ) ( " malformed GL_VERSION (%s) \n " , debugstr_a ( gl_string ) ) ;
+ + gl_string_cursor ;
cursor = 0 ;
while ( * gl_string_cursor < = ' 9 ' & & * gl_string_cursor > = ' 0 ' ) {
tmp [ cursor + + ] = * gl_string_cursor ;
+ + gl_string_cursor ;
}
tmp [ cursor ] = 0 ;
minor = atoi ( tmp ) ;
}
break ;
2005-07-10 19:48:07 +02:00
default :
major = 0 ;
minor = 9 ;
2004-09-29 23:26:47 +02:00
}
2008-02-05 22:49:14 +01:00
gl_info - > driver_version = MAKEDWORD_VERSION ( major , minor ) ;
TRACE_ ( d3d_caps ) ( " found driver version (%s)->%i.%i->(0x%08x) \n " , debugstr_a ( gl_string ) , major , minor , gl_info - > driver_version ) ;
2008-02-05 22:28:00 +01:00
/* Current Windows drivers have versions like 6.14.... (some older have an earlier version) */
2008-02-05 22:49:14 +01:00
gl_info - > driver_version_hipart = MAKEDWORD_VERSION ( 6 , 14 ) ;
2008-02-05 22:28:00 +01:00
} else {
FIXME ( " OpenGL driver did not return version information \n " ) ;
2008-02-05 22:49:14 +01:00
gl_info - > driver_version = MAKEDWORD_VERSION ( 0 , 0 ) ;
gl_info - > driver_version_hipart = MAKEDWORD_VERSION ( 6 , 14 ) ;
2004-09-29 23:26:47 +02:00
}
TRACE_ ( d3d_caps ) ( " found GL_RENDERER (%s)->(0x%04x) \n " , debugstr_a ( gl_info - > gl_renderer ) , gl_info - > gl_card ) ;
/*
* Initialize openGL extension related variables
* with Default values
*/
2008-07-11 22:58:34 +02:00
memset ( gl_info - > supported , 0 , sizeof ( gl_info - > supported ) ) ;
2006-08-09 18:24:08 +02:00
gl_info - > max_buffers = 1 ;
2006-06-27 23:40:42 +02:00
gl_info - > max_textures = 1 ;
gl_info - > max_texture_stages = 1 ;
2007-06-25 22:45:21 +02:00
gl_info - > max_fragment_samplers = 1 ;
2007-06-25 22:45:28 +02:00
gl_info - > max_vertex_samplers = 0 ;
2008-12-15 00:03:43 +01:00
gl_info - > max_combined_samplers = gl_info - > max_fragment_samplers + gl_info - > max_vertex_samplers ;
2006-06-27 23:40:42 +02:00
gl_info - > max_sampler_stages = 1 ;
2004-09-29 23:26:47 +02:00
gl_info - > ps_arb_version = PS_VERSION_NOT_SUPPORTED ;
2006-08-08 10:57:15 +02:00
gl_info - > ps_arb_max_temps = 0 ;
gl_info - > ps_arb_max_instructions = 0 ;
2004-09-29 23:26:47 +02:00
gl_info - > vs_arb_version = VS_VERSION_NOT_SUPPORTED ;
2006-08-08 10:57:15 +02:00
gl_info - > vs_arb_max_temps = 0 ;
gl_info - > vs_arb_max_instructions = 0 ;
2004-09-29 23:26:47 +02:00
gl_info - > vs_nv_version = VS_VERSION_NOT_SUPPORTED ;
gl_info - > vs_ati_version = VS_VERSION_NOT_SUPPORTED ;
2006-07-30 23:28:10 +02:00
gl_info - > vs_glsl_constantsF = 0 ;
gl_info - > ps_glsl_constantsF = 0 ;
gl_info - > vs_arb_constantsF = 0 ;
gl_info - > ps_arb_constantsF = 0 ;
2004-09-29 23:26:47 +02:00
/* Retrieve opengl defaults */
glGetIntegerv ( GL_MAX_CLIP_PLANES , & gl_max ) ;
2006-10-13 05:35:35 +02:00
gl_info - > max_clipplanes = min ( WINED3DMAXUSERCLIPPLANES , gl_max ) ;
2004-09-29 23:26:47 +02:00
TRACE_ ( d3d_caps ) ( " ClipPlanes support - num Planes=%d \n " , gl_max ) ;
glGetIntegerv ( GL_MAX_LIGHTS , & gl_max ) ;
gl_info - > max_lights = gl_max ;
TRACE_ ( d3d_caps ) ( " Lights support - max lights=%d \n " , gl_max ) ;
2005-07-10 19:48:07 +02:00
glGetIntegerv ( GL_MAX_TEXTURE_SIZE , & gl_max ) ;
gl_info - > max_texture_size = gl_max ;
TRACE_ ( d3d_caps ) ( " Maximum texture size support - max texture size=%d \n " , gl_max ) ;
2009-01-09 10:23:42 +01:00
glGetFloatv ( GL_ALIASED_POINT_SIZE_RANGE , gl_floatv ) ;
2007-11-03 15:39:22 +01:00
gl_info - > max_pointsizemin = gl_floatv [ 0 ] ;
2006-08-06 13:53:19 +02:00
gl_info - > max_pointsize = gl_floatv [ 1 ] ;
TRACE_ ( d3d_caps ) ( " Maximum point size support - max point size=%f \n " , gl_floatv [ 1 ] ) ;
2005-07-10 19:48:07 +02:00
2004-09-29 23:26:47 +02:00
/* Parse the gl supported features, in theory enabling parts of our code appropriately */
2005-08-11 12:57:47 +02:00
GL_Extensions = ( const char * ) glGetString ( GL_EXTENSIONS ) ;
2005-07-13 16:15:54 +02:00
TRACE_ ( d3d_caps ) ( " GL_Extensions reported: \n " ) ;
2004-09-29 23:26:47 +02:00
if ( NULL = = GL_Extensions ) {
2005-07-13 16:15:54 +02:00
ERR ( " GL_Extensions returns NULL \n " ) ;
2004-09-29 23:26:47 +02:00
} else {
while ( * GL_Extensions ! = 0x00 ) {
2007-08-08 18:57:39 +02:00
const char * Start ;
2004-09-29 23:26:47 +02:00
char ThisExtn [ 256 ] ;
2007-08-08 18:57:39 +02:00
size_t len ;
2004-09-29 23:26:47 +02:00
2007-08-08 18:57:39 +02:00
while ( isspace ( * GL_Extensions ) ) GL_Extensions + + ;
Start = GL_Extensions ;
while ( ! isspace ( * GL_Extensions ) & & * GL_Extensions ! = 0x00 ) {
2004-09-29 23:26:47 +02:00
GL_Extensions + + ;
}
2007-08-08 18:57:39 +02:00
len = GL_Extensions - Start ;
if ( len = = 0 | | len > = sizeof ( ThisExtn ) )
continue ;
memcpy ( ThisExtn , Start , len ) ;
ThisExtn [ len ] = ' \0 ' ;
2004-09-29 23:26:47 +02:00
TRACE_ ( d3d_caps ) ( " - %s \n " , ThisExtn ) ;
2007-06-26 23:05:41 +02:00
for ( i = 0 ; i < ( sizeof ( EXTENSION_MAP ) / sizeof ( * EXTENSION_MAP ) ) ; + + i ) {
if ( ! strcmp ( ThisExtn , EXTENSION_MAP [ i ] . extension_string ) ) {
TRACE_ ( d3d_caps ) ( " FOUND: %s support \n " , EXTENSION_MAP [ i ] . extension_string ) ;
gl_info - > supported [ EXTENSION_MAP [ i ] . extension ] = TRUE ;
break ;
2007-03-01 01:17:05 +01:00
}
2007-06-26 23:05:41 +02:00
}
}
2008-07-03 05:08:10 +02:00
LEAVE_GL ( ) ;
2007-11-06 01:25:30 +01:00
/* Now work out what GL support this card really has */
2007-11-11 13:59:49 +01:00
# define USE_GL_FUNC(type, pfn, ext, replace) { \
DWORD ver = ver_for_ext ( ext ) ; \
if ( gl_info - > supported [ ext ] ) gl_info - > pfn = ( type ) pwglGetProcAddress ( # pfn ) ; \
2008-02-05 22:49:14 +01:00
else if ( ver & & ver < = gl_info - > gl_version ) gl_info - > pfn = ( type ) pwglGetProcAddress ( # replace ) ; \
2007-11-11 13:59:49 +01:00
else gl_info - > pfn = NULL ; \
}
2007-11-06 01:25:30 +01:00
GL_EXT_FUNCS_GEN ;
2007-11-11 13:59:49 +01:00
# undef USE_GL_FUNC
# define USE_GL_FUNC(type, pfn, ext, replace) gl_info->pfn = (type) pwglGetProcAddress(#pfn);
2007-11-06 01:25:30 +01:00
WGL_EXT_FUNCS_GEN ;
# undef USE_GL_FUNC
2007-06-26 23:05:41 +02:00
2008-07-03 05:08:10 +02:00
ENTER_GL ( ) ;
2007-11-06 13:20:27 +01:00
/* Now mark all the extensions supported which are included in the opengl core version. Do this *after*
* loading the functions , otherwise the code above will load the extension entry points instead of the
* core functions , which may not work
*/
for ( i = 0 ; i < ( sizeof ( EXTENSION_MAP ) / sizeof ( * EXTENSION_MAP ) ) ; + + i ) {
if ( gl_info - > supported [ EXTENSION_MAP [ i ] . extension ] = = FALSE & &
2008-02-05 22:49:14 +01:00
EXTENSION_MAP [ i ] . version < = gl_info - > gl_version & & EXTENSION_MAP [ i ] . version ) {
2007-11-06 13:20:27 +01:00
TRACE_ ( d3d_caps ) ( " GL CORE: %s support \n " , EXTENSION_MAP [ i ] . extension_string ) ;
gl_info - > supported [ EXTENSION_MAP [ i ] . extension ] = TRUE ;
}
}
2007-06-26 23:05:41 +02:00
if ( gl_info - > supported [ APPLE_FENCE ] ) {
/* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
* The apple extension interacts with some other apple exts . Disable the NV
* extension if the apple one is support to prevent confusion in other parts
* of the code
2004-09-29 23:26:47 +02:00
*/
2007-06-26 23:05:41 +02:00
gl_info - > supported [ NV_FENCE ] = FALSE ;
}
2008-02-13 14:22:40 +01:00
if ( gl_info - > supported [ APPLE_FLOAT_PIXELS ] ) {
/* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
*
* The enums are the same :
* GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881A
* GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881B
* GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
* GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
* GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140B
*/
if ( ! gl_info - > supported [ ARB_TEXTURE_FLOAT ] ) {
TRACE_ ( d3d_caps ) ( " IMPLIED: GL_ARB_texture_float support(from GL_APPLE_float_pixels \n " ) ;
gl_info - > supported [ ARB_TEXTURE_FLOAT ] = TRUE ;
}
if ( ! gl_info - > supported [ ARB_HALF_FLOAT_PIXEL ] ) {
TRACE_ ( d3d_caps ) ( " IMPLIED: GL_ARB_half_float_pixel support(from GL_APPLE_float_pixels \n " ) ;
gl_info - > supported [ ARB_HALF_FLOAT_PIXEL ] = TRUE ;
}
}
2007-06-26 23:05:41 +02:00
if ( gl_info - > supported [ ARB_TEXTURE_CUBE_MAP ] ) {
TRACE_ ( d3d_caps ) ( " IMPLIED: NVIDIA (NV) Texture Gen Reflection support \n " ) ;
gl_info - > supported [ NV_TEXGEN_REFLECTION ] = TRUE ;
}
if ( gl_info - > supported [ NV_TEXTURE_SHADER2 ] ) {
2008-03-22 14:31:52 +01:00
if ( gl_info - > supported [ NV_REGISTER_COMBINERS ] ) {
2008-04-22 08:18:14 +02:00
/* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
2008-03-22 14:31:52 +01:00
* are supported . The nv extensions provide the same functionality as the
* ATI one , and a bit more ( signed pixelformats )
*/
gl_info - > supported [ ATI_FRAGMENT_SHADER ] = FALSE ;
}
2007-06-26 23:05:41 +02:00
}
if ( gl_info - > supported [ ARB_DRAW_BUFFERS ] ) {
glGetIntegerv ( GL_MAX_DRAW_BUFFERS_ARB , & gl_max ) ;
gl_info - > max_buffers = gl_max ;
TRACE_ ( d3d_caps ) ( " Max draw buffers: %u \n " , gl_max ) ;
}
if ( gl_info - > supported [ ARB_MULTITEXTURE ] ) {
glGetIntegerv ( GL_MAX_TEXTURE_UNITS_ARB , & gl_max ) ;
gl_info - > max_textures = min ( MAX_TEXTURES , gl_max ) ;
TRACE_ ( d3d_caps ) ( " Max textures: %d \n " , gl_info - > max_textures ) ;
if ( gl_info - > supported [ NV_REGISTER_COMBINERS ] ) {
GLint tmp ;
glGetIntegerv ( GL_MAX_GENERAL_COMBINERS_NV , & tmp ) ;
gl_info - > max_texture_stages = min ( MAX_TEXTURES , tmp ) ;
} else {
gl_info - > max_texture_stages = min ( MAX_TEXTURES , gl_max ) ;
2004-09-29 23:26:47 +02:00
}
2007-06-26 23:05:41 +02:00
TRACE_ ( d3d_caps ) ( " Max texture stages: %d \n " , gl_info - > max_texture_stages ) ;
2004-09-29 23:26:47 +02:00
2007-06-26 23:05:41 +02:00
if ( gl_info - > supported [ ARB_FRAGMENT_PROGRAM ] ) {
GLint tmp ;
glGetIntegerv ( GL_MAX_TEXTURE_IMAGE_UNITS_ARB , & tmp ) ;
2007-11-17 00:44:36 +01:00
gl_info - > max_fragment_samplers = min ( MAX_FRAGMENT_SAMPLERS , tmp ) ;
2007-06-26 23:05:41 +02:00
} else {
gl_info - > max_fragment_samplers = max ( gl_info - > max_fragment_samplers , gl_max ) ;
}
TRACE_ ( d3d_caps ) ( " Max fragment samplers: %d \n " , gl_info - > max_fragment_samplers ) ;
if ( gl_info - > supported [ ARB_VERTEX_SHADER ] ) {
GLint tmp ;
glGetIntegerv ( GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB , & tmp ) ;
gl_info - > max_vertex_samplers = tmp ;
glGetIntegerv ( GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB , & tmp ) ;
gl_info - > max_combined_samplers = tmp ;
2007-11-07 23:03:15 +01:00
/* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
* is known at shader link time . In a vertex shader + pixel shader combination this isn ' t
* an issue because then the sampler setup only depends on the two shaders . If a pixel
* shader is used with fixed function vertex processing we ' re fine too because fixed function
* vertex processing doesn ' t use any samplers . If fixed function fragment processing is
* used we have to make sure that all vertex sampler setups are valid together with all
* possible fixed function fragment processing setups . This is true if vsamplers + MAX_TEXTURES
* < = max_samplers . This is true on all d3d9 cards that support vtf ( gf 6 and gf7 cards ) .
* dx9 radeon cards do not support vertex texture fetch . DX10 cards have 128 samplers , and
* dx9 is limited to 8 fixed function texture stages and 4 vertex samplers . DX10 does not have
* a fixed function pipeline anymore .
*
* So this is just a check to check that our assumption holds true . If not , write a warning
2008-01-23 15:16:30 +01:00
* and reduce the number of vertex samplers or probably disable vertex texture fetch .
2007-11-07 23:03:15 +01:00
*/
if ( gl_info - > max_vertex_samplers & &
MAX_TEXTURES + gl_info - > max_vertex_samplers > gl_info - > max_combined_samplers ) {
FIXME ( " OpenGL implementation supports %u vertex samplers and %u total samplers \n " ,
gl_info - > max_vertex_samplers , gl_info - > max_combined_samplers ) ;
FIXME ( " Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers \n " ) ;
2007-12-01 02:53:10 +01:00
if ( gl_info - > max_combined_samplers > MAX_TEXTURES )
gl_info - > max_vertex_samplers =
gl_info - > max_combined_samplers - MAX_TEXTURES ;
else
gl_info - > max_vertex_samplers = 0 ;
2007-11-07 23:03:15 +01:00
}
2007-06-26 23:05:41 +02:00
} else {
gl_info - > max_combined_samplers = gl_info - > max_fragment_samplers ;
}
TRACE_ ( d3d_caps ) ( " Max vertex samplers: %u \n " , gl_info - > max_vertex_samplers ) ;
TRACE_ ( d3d_caps ) ( " Max combined samplers: %u \n " , gl_info - > max_combined_samplers ) ;
}
if ( gl_info - > supported [ ARB_VERTEX_BLEND ] ) {
glGetIntegerv ( GL_MAX_VERTEX_UNITS_ARB , & gl_max ) ;
gl_info - > max_blends = gl_max ;
TRACE_ ( d3d_caps ) ( " Max blends: %u \n " , gl_info - > max_blends ) ;
}
if ( gl_info - > supported [ EXT_TEXTURE3D ] ) {
glGetIntegerv ( GL_MAX_3D_TEXTURE_SIZE_EXT , & gl_max ) ;
gl_info - > max_texture3d_size = gl_max ;
TRACE_ ( d3d_caps ) ( " Max texture3D size: %d \n " , gl_info - > max_texture3d_size ) ;
}
if ( gl_info - > supported [ EXT_TEXTURE_FILTER_ANISOTROPIC ] ) {
glGetIntegerv ( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT , & gl_max ) ;
gl_info - > max_anisotropy = gl_max ;
TRACE_ ( d3d_caps ) ( " Max anisotropy: %d \n " , gl_info - > max_anisotropy ) ;
}
if ( gl_info - > supported [ ARB_FRAGMENT_PROGRAM ] ) {
gl_info - > ps_arb_version = PS_VERSION_11 ;
GL_EXTCALL ( glGetProgramivARB ( GL_FRAGMENT_PROGRAM_ARB , GL_MAX_PROGRAM_ENV_PARAMETERS_ARB , & gl_max ) ) ;
gl_info - > ps_arb_constantsF = gl_max ;
TRACE_ ( d3d_caps ) ( " Max ARB_FRAGMENT_PROGRAM float constants: %d \n " , gl_info - > ps_arb_constantsF ) ;
2007-10-27 21:54:32 +02:00
GL_EXTCALL ( glGetProgramivARB ( GL_FRAGMENT_PROGRAM_ARB , GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB , & gl_max ) ) ;
2007-06-26 23:05:41 +02:00
gl_info - > ps_arb_max_temps = gl_max ;
2007-10-27 21:54:32 +02:00
TRACE_ ( d3d_caps ) ( " Max ARB_FRAGMENT_PROGRAM native temporaries: %d \n " , gl_info - > ps_arb_max_temps ) ;
GL_EXTCALL ( glGetProgramivARB ( GL_FRAGMENT_PROGRAM_ARB , GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB , & gl_max ) ) ;
2007-06-26 23:05:41 +02:00
gl_info - > ps_arb_max_instructions = gl_max ;
2007-10-27 21:54:32 +02:00
TRACE_ ( d3d_caps ) ( " Max ARB_FRAGMENT_PROGRAM native instructions: %d \n " , gl_info - > ps_arb_max_instructions ) ;
2004-09-29 23:26:47 +02:00
}
2007-06-26 23:05:41 +02:00
if ( gl_info - > supported [ ARB_VERTEX_PROGRAM ] ) {
gl_info - > vs_arb_version = VS_VERSION_11 ;
GL_EXTCALL ( glGetProgramivARB ( GL_VERTEX_PROGRAM_ARB , GL_MAX_PROGRAM_ENV_PARAMETERS_ARB , & gl_max ) ) ;
gl_info - > vs_arb_constantsF = gl_max ;
TRACE_ ( d3d_caps ) ( " Max ARB_VERTEX_PROGRAM float constants: %d \n " , gl_info - > vs_arb_constantsF ) ;
2007-10-27 21:54:32 +02:00
GL_EXTCALL ( glGetProgramivARB ( GL_VERTEX_PROGRAM_ARB , GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB , & gl_max ) ) ;
2007-06-26 23:05:41 +02:00
gl_info - > vs_arb_max_temps = gl_max ;
2007-10-27 21:54:32 +02:00
TRACE_ ( d3d_caps ) ( " Max ARB_VERTEX_PROGRAM native temporaries: %d \n " , gl_info - > vs_arb_max_temps ) ;
GL_EXTCALL ( glGetProgramivARB ( GL_VERTEX_PROGRAM_ARB , GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB , & gl_max ) ) ;
2007-06-26 23:05:41 +02:00
gl_info - > vs_arb_max_instructions = gl_max ;
2007-10-27 21:54:32 +02:00
TRACE_ ( d3d_caps ) ( " Max ARB_VERTEX_PROGRAM native instructions: %d \n " , gl_info - > vs_arb_max_instructions ) ;
2007-11-07 19:57:49 +01:00
gl_info - > arb_vs_offset_limit = test_arb_vs_offset_limit ( gl_info ) ;
2007-06-26 23:05:41 +02:00
}
if ( gl_info - > supported [ ARB_VERTEX_SHADER ] ) {
glGetIntegerv ( GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB , & gl_max ) ;
gl_info - > vs_glsl_constantsF = gl_max / 4 ;
TRACE_ ( d3d_caps ) ( " Max ARB_VERTEX_SHADER float constants: %u \n " , gl_info - > vs_glsl_constantsF ) ;
}
if ( gl_info - > supported [ ARB_FRAGMENT_SHADER ] ) {
glGetIntegerv ( GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB , & gl_max ) ;
gl_info - > ps_glsl_constantsF = gl_max / 4 ;
TRACE_ ( d3d_caps ) ( " Max ARB_FRAGMENT_SHADER float constants: %u \n " , gl_info - > ps_glsl_constantsF ) ;
2007-10-24 13:16:57 +02:00
glGetIntegerv ( GL_MAX_VARYING_FLOATS_ARB , & gl_max ) ;
gl_info - > max_glsl_varyings = gl_max ;
TRACE_ ( d3d_caps ) ( " Max GLSL varyings: %u (%u 4 component varyings) \n " , gl_max , gl_max / 4 ) ;
2007-06-26 23:05:41 +02:00
}
if ( gl_info - > supported [ EXT_VERTEX_SHADER ] ) {
gl_info - > vs_ati_version = VS_VERSION_11 ;
}
if ( gl_info - > supported [ NV_VERTEX_PROGRAM3 ] ) {
gl_info - > vs_nv_version = VS_VERSION_30 ;
} else if ( gl_info - > supported [ NV_VERTEX_PROGRAM2 ] ) {
gl_info - > vs_nv_version = VS_VERSION_20 ;
} else if ( gl_info - > supported [ NV_VERTEX_PROGRAM1_1 ] ) {
gl_info - > vs_nv_version = VS_VERSION_11 ;
} else if ( gl_info - > supported [ NV_VERTEX_PROGRAM ] ) {
gl_info - > vs_nv_version = VS_VERSION_10 ;
}
if ( gl_info - > supported [ NV_FRAGMENT_PROGRAM2 ] ) {
gl_info - > ps_nv_version = PS_VERSION_30 ;
} else if ( gl_info - > supported [ NV_FRAGMENT_PROGRAM ] ) {
gl_info - > ps_nv_version = PS_VERSION_20 ;
}
2008-03-02 00:02:18 +01:00
if ( gl_info - > supported [ NV_LIGHT_MAX_EXPONENT ] ) {
glGetFloatv ( GL_MAX_SHININESS_NV , & gl_info - > max_shininess ) ;
} else {
gl_info - > max_shininess = 128.0 ;
}
2007-11-26 23:19:03 +01:00
if ( gl_info - > supported [ ARB_TEXTURE_NON_POWER_OF_TWO ] ) {
/* If we have full NP2 texture support, disable GL_ARB_texture_rectangle because we will never use it.
* This saves a few redundant glDisable calls
*/
gl_info - > supported [ ARB_TEXTURE_RECTANGLE ] = FALSE ;
}
2008-03-22 14:31:52 +01:00
if ( gl_info - > supported [ ATI_FRAGMENT_SHADER ] ) {
/* Disable NV_register_combiners and fragment shader if this is supported.
2008-04-07 13:01:02 +02:00
* generally the NV extensions are preferred over the ATI ones , and this
2008-03-22 14:31:52 +01:00
* extension is disabled if register_combiners and texture_shader2 are both
* supported . So we reach this place only if we have incomplete NV dxlevel 8
* fragment processing support
*/
gl_info - > supported [ NV_REGISTER_COMBINERS ] = FALSE ;
gl_info - > supported [ NV_REGISTER_COMBINERS2 ] = FALSE ;
gl_info - > supported [ NV_TEXTURE_SHADER ] = FALSE ;
gl_info - > supported [ NV_TEXTURE_SHADER2 ] = FALSE ;
gl_info - > supported [ NV_TEXTURE_SHADER3 ] = FALSE ;
}
2007-06-26 23:05:41 +02:00
2004-09-29 23:26:47 +02:00
}
2006-07-30 23:28:10 +02:00
checkGLcall ( " extension detection \n " ) ;
2006-09-26 20:31:52 +02:00
/* In some cases the number of texture stages can be larger than the number
* of samplers . The GF4 for example can use only 2 samplers ( no fragment
* shaders ) , but 8 texture stages ( register combiners ) . */
2007-06-25 22:45:21 +02:00
gl_info - > max_sampler_stages = max ( gl_info - > max_fragment_samplers , gl_info - > max_texture_stages ) ;
2004-09-29 23:26:47 +02:00
2006-11-17 13:24:00 +01:00
/* We can only use ORM_FBO when the hardware supports it. */
if ( wined3d_settings . offscreen_rendering_mode = = ORM_FBO & & ! gl_info - > supported [ EXT_FRAMEBUFFER_OBJECT ] ) {
WARN_ ( d3d_caps ) ( " GL_EXT_framebuffer_object not supported, falling back to PBuffer offscreen rendering mode. \n " ) ;
wined3d_settings . offscreen_rendering_mode = ORM_PBUFFER ;
2006-09-26 20:31:48 +02:00
}
2006-12-19 19:25:42 +01:00
/* MRTs are currently only supported when FBOs are used. */
if ( wined3d_settings . offscreen_rendering_mode ! = ORM_FBO ) {
gl_info - > max_buffers = 1 ;
}
2006-08-19 11:58:23 +02:00
/* Below is a list of Nvidia and ATI GPUs. Both vendors have dozens of different GPUs with roughly the same
* features . In most cases GPUs from a certain family differ in clockspeeds , the amount of video memory and
* in case of the latest videocards in the number of pixel / vertex pipelines .
*
* A Direct3D device object contains the PCI id ( vendor + device ) of the videocard which is used for
* rendering . Various games use this information to get a rough estimation of the features of the card
* and some might use it for enabling 3 d effects only on certain types of videocards . In some cases
* games might even use it to work around bugs which happen on certain videocards / driver combinations .
* The problem is that OpenGL only exposes a rendering string containing the name of the videocard and
* not the PCI id .
*
* Various games depend on the PCI id , so somehow we need to provide one . A simple option is to parse
* the renderer string and translate this to the right PCI id . This is a lot of work because there are more
* than 200 GPUs just for Nvidia . Various cards share the same renderer string , so the amount of code might
* be ' small ' but there are quite a number of exceptions which would make this a pain to maintain .
* Another way would be to query the PCI id from the operating system ( assuming this is the videocard which
2006-09-07 20:01:50 +02:00
* is used for rendering which is not always the case ) . This would work but it is not very portable . Second
* it would not work well in , let ' s say , a remote X situation in which the amount of 3 d features which can be used
2006-08-19 11:58:23 +02:00
* is limited .
*
* As said most games only use the PCI id to get an indication of the capabilities of the card .
* It doesn ' t really matter if the given id is the correct one if we return the id of a card with
* similar 3 d features .
*
* The code below checks the OpenGL capabilities of a videocard and matches that to a certain level of
* Direct3D functionality . Once a card passes the Direct3D9 check , we know that the card ( in case of Nvidia )
2006-09-07 20:01:50 +02:00
* is at least a GeforceFX . To give a better estimate we do a basic check on the renderer string but if that
2006-08-19 11:58:23 +02:00
* won ' t pass we return a default card . This way is better than maintaining a full card database as even
* without a full database we can return a card with similar features . Second the size of the database
* can be made quite small because when you know what type of 3 d functionality a card has , you know to which
* GPU family the GPU must belong . Because of this you only have to check a small part of the renderer string
2007-09-17 22:16:48 +02:00
* to distinguishes between different models from that family .
*
* The code also selects a default amount of video memory which we will use for an estimation of the amount
* of free texture memory . In case of real D3D the amount of texture memory includes video memory and system
* memory ( to be specific AGP memory or in case of PCIE TurboCache / HyperMemory ) . We don ' t know how much
* system memory can be addressed by the system but we can make a reasonable estimation about the amount of
* video memory . If the value is slightly wrong it doesn ' t matter as we didn ' t include AGP - like memory which
* makes the amount of addressable memory higher and second OpenGL isn ' t that critical it moves to system
* memory behind our backs if really needed .
2008-01-09 20:37:05 +01:00
* Note that the amount of video memory can be overruled using a registry setting .
2006-08-19 11:58:23 +02:00
*/
switch ( gl_info - > gl_vendor ) {
case VENDOR_NVIDIA :
2006-09-07 20:01:50 +02:00
/* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
* shader capabilities , so we use the shader capabilities to distinguish between FX and 6 xxx / 7 xxx .
2006-08-19 11:58:23 +02:00
*/
if ( WINE_D3D9_CAPABLE ( gl_info ) & & ( gl_info - > vs_nv_version = = VS_VERSION_30 ) ) {
2008-11-22 00:54:46 +01:00
/* Geforce GTX - highend */
if ( strstr ( gl_info - > gl_renderer , " GTX 280 " ) ) {
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_GTX280 ;
vidmem = 1024 ;
}
2008-06-08 17:37:20 +02:00
/* Geforce9 - highend */
2008-11-22 00:54:46 +01:00
else if ( strstr ( gl_info - > gl_renderer , " 9800 " ) ) {
2008-06-08 17:37:20 +02:00
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_9800GT ;
vidmem = 512 ;
}
/* Geforce9 - midend */
else if ( strstr ( gl_info - > gl_renderer , " 9600 " ) ) {
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_9600GT ;
vidmem = 384 ; /* The 9600GSO has 384MB, the 9600GT has 512-1024MB */
}
2007-09-17 22:16:48 +02:00
/* Geforce8 - highend */
2008-09-19 01:18:23 +02:00
else if ( strstr ( gl_info - > gl_renderer , " 8800 " ) ) {
2007-08-24 19:16:30 +02:00
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_8800GTS ;
2007-09-17 22:16:48 +02:00
vidmem = 320 ; /* The 8800GTS uses 320MB, a 8800GTX can have 768MB */
}
2007-12-11 17:18:23 +01:00
/* Geforce8 - midend mobile */
else if ( strstr ( gl_info - > gl_renderer , " 8600 M " ) ) {
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_8600MGT ;
vidmem = 512 ;
}
2007-09-17 22:16:48 +02:00
/* Geforce8 - midend */
2007-08-24 19:16:30 +02:00
else if ( strstr ( gl_info - > gl_renderer , " 8600 " ) | |
strstr ( gl_info - > gl_renderer , " 8700 " ) )
2007-09-17 22:16:48 +02:00
{
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_8600GT ;
vidmem = 256 ;
}
/* Geforce8 - lowend */
2007-08-24 19:16:30 +02:00
else if ( strstr ( gl_info - > gl_renderer , " 8300 " ) | |
strstr ( gl_info - > gl_renderer , " 8400 " ) | |
strstr ( gl_info - > gl_renderer , " 8500 " ) )
2007-09-17 22:16:48 +02:00
{
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_8300GS ;
vidmem = 128 ; /* 128-256MB for a 8300, 256-512MB for a 8400 */
}
/* Geforce7 - highend */
2007-08-24 19:16:30 +02:00
else if ( strstr ( gl_info - > gl_renderer , " 7800 " ) | |
strstr ( gl_info - > gl_renderer , " 7900 " ) | |
strstr ( gl_info - > gl_renderer , " 7950 " ) | |
strstr ( gl_info - > gl_renderer , " Quadro FX 4 " ) | |
strstr ( gl_info - > gl_renderer , " Quadro FX 5 " ) )
2007-09-17 22:16:48 +02:00
{
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_7800GT ;
vidmem = 256 ; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */
}
2007-11-23 01:53:02 +01:00
/* Geforce7 midend */
else if ( strstr ( gl_info - > gl_renderer , " 7600 " ) | |
strstr ( gl_info - > gl_renderer , " 7700 " ) ) {
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_7600 ;
vidmem = 256 ; /* The 7600 uses 256-512MB */
/* Geforce7 lower medium */
} else if ( strstr ( gl_info - > gl_renderer , " 7400 " ) ) {
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_7400 ;
vidmem = 256 ; /* The 7400 uses 256-512MB */
}
2008-01-01 15:29:58 +01:00
/* Geforce7 lowend */
else if ( strstr ( gl_info - > gl_renderer , " 7300 " ) ) {
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_7300 ;
vidmem = 256 ; /* Mac Pros with this card have 256 MB */
}
2007-11-23 01:53:02 +01:00
/* Geforce6 highend */
else if ( strstr ( gl_info - > gl_renderer , " 6800 " ) )
2007-09-17 22:16:48 +02:00
{
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_6800 ;
vidmem = 128 ; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */
}
/* Geforce6 - midend */
2006-08-19 11:58:23 +02:00
else if ( strstr ( gl_info - > gl_renderer , " 6600 " ) | |
strstr ( gl_info - > gl_renderer , " 6610 " ) | |
strstr ( gl_info - > gl_renderer , " 6700 " ) )
2007-09-17 22:16:48 +02:00
{
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_6600GT ;
vidmem = 128 ; /* A 6600GT has 128-256MB */
}
/* Geforce6/7 lowend */
else {
2007-09-16 13:08:54 +02:00
gl_info - > gl_card = CARD_NVIDIA_GEFORCE_6200 ; /* Geforce 6100/6150/6200/7300/7400/7500 */
2007-09-17 22:16:48 +02:00
vidmem = 64 ; /* */
}
2006-08-19 11:58:23 +02:00
} else if ( WINE_D3D9_CAPABLE ( gl_info ) ) {
2007-09-17 22:16:48 +02:00
/* GeforceFX - highend */
2006-08-19 11:58:23 +02:00
if ( strstr ( gl_info - > gl_renderer , " 5800 " ) | |
strstr ( gl_info - > gl_renderer , " 5900 " ) | |
strstr ( gl_info - > gl_renderer , " 5950 " ) | |
strstr ( gl_info - > gl_renderer , " Quadro FX " ) )
2007-09-17 22:16:48 +02:00
{
gl_info - > gl_card = CARD_NVIDIA_GEFORCEFX_5800 ;
vidmem = 256 ; /* 5800-5900 cards use 256MB */
}
/* GeforceFX - midend */
2006-08-19 11:58:23 +02:00
else if ( strstr ( gl_info - > gl_renderer , " 5600 " ) | |
strstr ( gl_info - > gl_renderer , " 5650 " ) | |
strstr ( gl_info - > gl_renderer , " 5700 " ) | |
strstr ( gl_info - > gl_renderer , " 5750 " ) )
2007-09-17 22:16:48 +02:00
{
gl_info - > gl_card = CARD_NVIDIA_GEFORCEFX_5600 ;
vidmem = 128 ; /* A 5600 uses 128-256MB */
}
/* GeforceFX - lowend */
else {
2006-08-19 11:58:23 +02:00
gl_info - > gl_card = CARD_NVIDIA_GEFORCEFX_5200 ; /* GeforceFX 5100/5200/5250/5300/5500 */
2007-09-17 22:16:48 +02:00
vidmem = 64 ; /* Normal FX5200 cards use 64-256MB; laptop (non-standard) can have less */
}
2006-08-19 11:58:23 +02:00
} else if ( WINE_D3D8_CAPABLE ( gl_info ) ) {
2007-09-17 22:16:48 +02:00
if ( strstr ( gl_info - > gl_renderer , " GeForce4 Ti " ) | | strstr ( gl_info - > gl_renderer , " Quadro4 " ) ) {
2006-08-19 11:58:23 +02:00
gl_info - > gl_card = CARD_NVIDIA_GEFORCE4_TI4200 ; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
2007-09-17 22:16:48 +02:00
vidmem = 64 ; /* Geforce4 Ti cards have 64-128MB */
}
else {
2006-08-19 11:58:23 +02:00
gl_info - > gl_card = CARD_NVIDIA_GEFORCE3 ; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
2007-09-17 22:16:48 +02:00
vidmem = 64 ; /* Geforce3 cards have 64-128MB */
}
2006-08-19 11:58:23 +02:00
} else if ( WINE_D3D7_CAPABLE ( gl_info ) ) {
2007-09-17 22:16:48 +02:00
if ( strstr ( gl_info - > gl_renderer , " GeForce4 MX " ) ) {
2006-08-19 11:58:23 +02:00
gl_info - > gl_card = CARD_NVIDIA_GEFORCE4_MX ; /* MX420/MX440/MX460/MX4000 */
2007-09-17 22:16:48 +02:00
vidmem = 64 ; /* Most Geforce4MX GPUs have at least 64MB of memory, some early models had 32MB but most have 64MB or even 128MB */
}
else if ( strstr ( gl_info - > gl_renderer , " GeForce2 MX " ) | | strstr ( gl_info - > gl_renderer , " Quadro2 MXR " ) ) {
2006-08-19 11:58:23 +02:00
gl_info - > gl_card = CARD_NVIDIA_GEFORCE2_MX ; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
2007-09-17 22:16:48 +02:00
vidmem = 32 ; /* Geforce2MX GPUs have 32-64MB of video memory */
}
else if ( strstr ( gl_info - > gl_renderer , " GeForce2 " ) | | strstr ( gl_info - > gl_renderer , " Quadro2 " ) ) {
2006-08-19 11:58:23 +02:00
gl_info - > gl_card = CARD_NVIDIA_GEFORCE2 ; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
2007-09-17 22:16:48 +02:00
vidmem = 32 ; /* Geforce2 GPUs have 32-64MB of video memory */
}
else {
2006-08-19 11:58:23 +02:00
gl_info - > gl_card = CARD_NVIDIA_GEFORCE ; /* Geforce 256/DDR, Quadro */
2007-09-17 22:16:48 +02:00
vidmem = 32 ; /* Most Geforce1 cards have 32MB, there are also some rare 16 and 64MB (Dell) models */
}
2006-08-19 11:58:23 +02:00
} else {
2007-09-17 22:16:48 +02:00
if ( strstr ( gl_info - > gl_renderer , " TNT2 " ) ) {
2006-08-19 11:58:23 +02:00
gl_info - > gl_card = CARD_NVIDIA_RIVA_TNT2 ; /* Riva TNT2 standard/M64/Pro/Ultra */
2007-09-17 22:16:48 +02:00
vidmem = 32 ; /* Most TNT2 boards have 32MB, though there are 16MB boards too */
}
else {
2006-08-19 11:58:23 +02:00
gl_info - > gl_card = CARD_NVIDIA_RIVA_TNT ; /* Riva TNT, Vanta */
2007-09-17 22:16:48 +02:00
vidmem = 16 ; /* Most TNT boards have 16MB, some rare models have 8MB */
}
2006-08-19 11:58:23 +02:00
}
break ;
case VENDOR_ATI :
if ( WINE_D3D9_CAPABLE ( gl_info ) ) {
2008-06-08 18:35:14 +02:00
/* Radeon R6xx HD2900/HD3800 - highend */
if ( strstr ( gl_info - > gl_renderer , " HD 2900 " ) | |
strstr ( gl_info - > gl_renderer , " HD 3870 " ) | |
strstr ( gl_info - > gl_renderer , " HD 3850 " ) )
{
2007-09-16 13:08:54 +02:00
gl_info - > gl_card = CARD_ATI_RADEON_HD2900 ;
2008-06-08 18:35:14 +02:00
vidmem = 512 ; /* HD2900/HD3800 uses 256-1024MB */
2007-09-17 22:16:48 +02:00
}
2008-06-08 18:35:14 +02:00
/* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
else if ( strstr ( gl_info - > gl_renderer , " HD 2600 " ) | |
strstr ( gl_info - > gl_renderer , " HD 3830 " ) | |
strstr ( gl_info - > gl_renderer , " HD 3690 " ) | |
strstr ( gl_info - > gl_renderer , " HD 3650 " ) )
{
2007-09-16 13:08:54 +02:00
gl_info - > gl_card = CARD_ATI_RADEON_HD2600 ;
2008-06-08 18:35:14 +02:00
vidmem = 256 ; /* HD2600/HD3600 uses 256-512MB */
2007-09-17 22:16:48 +02:00
}
2008-06-08 18:35:14 +02:00
/* Radeon R6xx HD2300/HD2400/HD3400 - lowend */
2007-09-16 13:08:54 +02:00
else if ( strstr ( gl_info - > gl_renderer , " HD 2300 " ) | |
2008-06-08 18:35:14 +02:00
strstr ( gl_info - > gl_renderer , " HD 2400 " ) | |
strstr ( gl_info - > gl_renderer , " HD 3470 " ) | |
strstr ( gl_info - > gl_renderer , " HD 3450 " ) | |
strstr ( gl_info - > gl_renderer , " HD 3430 " ) )
2007-09-17 22:16:48 +02:00
{
gl_info - > gl_card = CARD_ATI_RADEON_HD2300 ;
vidmem = 128 ; /* HD2300 uses at least 128MB, HD2400 uses 256MB */
}
2008-06-08 18:35:14 +02:00
/* Radeon R6xx/R7xx integrated */
else if ( strstr ( gl_info - > gl_renderer , " HD 3100 " ) | |
strstr ( gl_info - > gl_renderer , " HD 3200 " ) | |
strstr ( gl_info - > gl_renderer , " HD 3300 " ) )
{
gl_info - > gl_card = CARD_ATI_RADEON_HD3200 ;
vidmem = 128 ; /* 128MB */
}
2006-08-19 11:58:23 +02:00
/* Radeon R5xx */
2007-09-16 13:08:54 +02:00
else if ( strstr ( gl_info - > gl_renderer , " X1600 " ) | |
strstr ( gl_info - > gl_renderer , " X1650 " ) | |
strstr ( gl_info - > gl_renderer , " X1800 " ) | |
strstr ( gl_info - > gl_renderer , " X1900 " ) | |
strstr ( gl_info - > gl_renderer , " X1950 " ) )
2007-09-17 22:16:48 +02:00
{
gl_info - > gl_card = CARD_ATI_RADEON_X1600 ;
vidmem = 128 ; /* X1600 uses 128-256MB, >=X1800 uses 256MB */
}
2007-09-16 13:08:54 +02:00
/* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */
2006-08-19 11:58:23 +02:00
else if ( strstr ( gl_info - > gl_renderer , " X700 " ) | |
strstr ( gl_info - > gl_renderer , " X800 " ) | |
strstr ( gl_info - > gl_renderer , " X850 " ) | |
strstr ( gl_info - > gl_renderer , " X1300 " ) | |
2007-09-16 13:08:54 +02:00
strstr ( gl_info - > gl_renderer , " X1400 " ) | |
strstr ( gl_info - > gl_renderer , " X1450 " ) | |
strstr ( gl_info - > gl_renderer , " X1550 " ) )
2007-09-17 22:16:48 +02:00
{
gl_info - > gl_card = CARD_ATI_RADEON_X700 ;
vidmem = 128 ; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */
}
2009-01-20 17:09:24 +01:00
/* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
else if ( strstr ( gl_info - > gl_renderer , " Radeon Xpress " ) )
{
gl_info - > gl_card = CARD_ATI_RADEON_XPRESS_200M ;
vidmem = 64 ; /* Shared RAM, BIOS configurable, 64-256M */
}
2006-08-19 11:58:23 +02:00
/* Radeon R3xx */
2007-09-17 22:16:48 +02:00
else {
2006-08-19 11:58:23 +02:00
gl_info - > gl_card = CARD_ATI_RADEON_9500 ; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
2007-09-27 18:57:51 +02:00
vidmem = 64 ; /* Radeon 9500 uses 64MB, higher models use up to 256MB */
2007-09-17 22:16:48 +02:00
}
2006-08-19 11:58:23 +02:00
} else if ( WINE_D3D8_CAPABLE ( gl_info ) ) {
2007-09-17 22:16:48 +02:00
gl_info - > gl_card = CARD_ATI_RADEON_8500 ; /* Radeon 8500/9000/9100/9200/9300 */
vidmem = 64 ; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */
2006-08-19 11:58:23 +02:00
} else if ( WINE_D3D7_CAPABLE ( gl_info ) ) {
2007-09-17 22:16:48 +02:00
gl_info - > gl_card = CARD_ATI_RADEON_7200 ; /* Radeon 7000/7100/7200/7500 */
2007-09-27 18:57:51 +02:00
vidmem = 32 ; /* There are models with up to 64MB */
2007-11-11 00:42:14 +01:00
} else {
2006-08-19 11:58:23 +02:00
gl_info - > gl_card = CARD_ATI_RAGE_128PRO ;
2007-09-17 22:16:48 +02:00
vidmem = 16 ; /* There are 16-32MB models */
2007-11-11 00:42:14 +01:00
}
2006-08-19 11:58:23 +02:00
break ;
case VENDOR_INTEL :
2008-12-27 23:51:47 +01:00
if ( strstr ( gl_info - > gl_renderer , " GMA 950 " ) | |
strstr ( gl_info - > gl_renderer , " 945GM " ) ) {
2007-11-30 16:51:32 +01:00
/* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
gl_info - > gl_card = CARD_INTEL_I945GM ;
vidmem = 64 ;
} else if ( strstr ( gl_info - > gl_renderer , " 915GM " ) ) {
2006-08-19 11:58:23 +02:00
gl_info - > gl_card = CARD_INTEL_I915GM ;
} else if ( strstr ( gl_info - > gl_renderer , " 915G " ) ) {
gl_info - > gl_card = CARD_INTEL_I915G ;
} else if ( strstr ( gl_info - > gl_renderer , " 865G " ) ) {
gl_info - > gl_card = CARD_INTEL_I865G ;
} else if ( strstr ( gl_info - > gl_renderer , " 855G " ) ) {
gl_info - > gl_card = CARD_INTEL_I855G ;
} else if ( strstr ( gl_info - > gl_renderer , " 830G " ) ) {
gl_info - > gl_card = CARD_INTEL_I830G ;
} else {
gl_info - > gl_card = CARD_INTEL_I915G ;
}
break ;
case VENDOR_MESA :
case VENDOR_WINE :
default :
/* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
* for Nvidia was because the hardware and drivers they make are of good quality . This makes
* them a good generic choice .
*/
gl_info - > gl_vendor = VENDOR_NVIDIA ;
if ( WINE_D3D9_CAPABLE ( gl_info ) )
gl_info - > gl_card = CARD_NVIDIA_GEFORCEFX_5600 ;
else if ( WINE_D3D8_CAPABLE ( gl_info ) )
2007-09-16 13:08:54 +02:00
gl_info - > gl_card = CARD_NVIDIA_GEFORCE3 ;
2006-08-19 11:58:23 +02:00
else if ( WINE_D3D7_CAPABLE ( gl_info ) )
gl_info - > gl_card = CARD_NVIDIA_GEFORCE ;
else if ( WINE_D3D6_CAPABLE ( gl_info ) )
gl_info - > gl_card = CARD_NVIDIA_RIVA_TNT ;
else
gl_info - > gl_card = CARD_NVIDIA_RIVA_128 ;
}
2007-11-30 16:51:32 +01:00
TRACE_ ( d3d_caps ) ( " FOUND (fake) card: 0x%x (vendor id), 0x%x (device id) \n " , gl_info - > gl_vendor , gl_info - > gl_card ) ;
2006-08-19 11:58:23 +02:00
2007-09-23 00:46:21 +02:00
/* If we have an estimate use it, else default to 64MB; */
if ( vidmem )
gl_info - > vidmem = vidmem * 1024 * 1024 ; /* convert from MBs to bytes */
else
gl_info - > vidmem = WINE_DEFAULT_VIDMEM ;
2007-09-17 22:16:48 +02:00
2008-11-28 15:30:11 +01:00
/* Load all the lookup tables */
2005-08-03 13:00:28 +02:00
for ( i = 0 ; i < MAX_LOOKUPS ; i + + ) {
2005-10-03 12:15:08 +02:00
stateLookup [ i ] = HeapAlloc ( GetProcessHeap ( ) , 0 , sizeof ( * stateLookup [ i ] ) * ( 1 + maxLookup [ i ] - minLookup [ i ] ) ) ;
2005-08-03 13:00:28 +02:00
}
2006-10-24 12:03:18 +02:00
stateLookup [ WINELOOKUP_WARPPARAM ] [ WINED3DTADDRESS_WRAP - minLookup [ WINELOOKUP_WARPPARAM ] ] = GL_REPEAT ;
stateLookup [ WINELOOKUP_WARPPARAM ] [ WINED3DTADDRESS_CLAMP - minLookup [ WINELOOKUP_WARPPARAM ] ] = GL_CLAMP_TO_EDGE ;
stateLookup [ WINELOOKUP_WARPPARAM ] [ WINED3DTADDRESS_BORDER - minLookup [ WINELOOKUP_WARPPARAM ] ] =
2005-08-03 13:00:28 +02:00
gl_info - > supported [ ARB_TEXTURE_BORDER_CLAMP ] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT ;
2006-10-24 12:03:18 +02:00
stateLookup [ WINELOOKUP_WARPPARAM ] [ WINED3DTADDRESS_BORDER - minLookup [ WINELOOKUP_WARPPARAM ] ] =
2005-08-03 13:00:28 +02:00
gl_info - > supported [ ARB_TEXTURE_BORDER_CLAMP ] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT ;
2006-10-24 12:03:18 +02:00
stateLookup [ WINELOOKUP_WARPPARAM ] [ WINED3DTADDRESS_MIRROR - minLookup [ WINELOOKUP_WARPPARAM ] ] =
2005-08-03 13:00:28 +02:00
gl_info - > supported [ ARB_TEXTURE_MIRRORED_REPEAT ] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT ;
2006-10-24 12:03:18 +02:00
stateLookup [ WINELOOKUP_WARPPARAM ] [ WINED3DTADDRESS_MIRRORONCE - minLookup [ WINELOOKUP_WARPPARAM ] ] =
2005-08-03 13:00:28 +02:00
gl_info - > supported [ ATI_TEXTURE_MIRROR_ONCE ] ? GL_MIRROR_CLAMP_TO_EDGE_ATI : GL_REPEAT ;
2008-04-06 00:31:39 +02:00
magLookup [ WINED3DTEXF_NONE - WINED3DTEXF_NONE ] = GL_NEAREST ;
magLookup [ WINED3DTEXF_POINT - WINED3DTEXF_NONE ] = GL_NEAREST ;
magLookup [ WINED3DTEXF_LINEAR - WINED3DTEXF_NONE ] = GL_LINEAR ;
magLookup [ WINED3DTEXF_ANISOTROPIC - WINED3DTEXF_NONE ] =
2005-08-03 13:00:28 +02:00
gl_info - > supported [ EXT_TEXTURE_FILTER_ANISOTROPIC ] ? GL_LINEAR : GL_NEAREST ;
2008-11-26 16:14:40 +01:00
minMipLookup [ WINED3DTEXF_NONE ] . mip [ WINED3DTEXF_NONE ] = GL_LINEAR ;
minMipLookup [ WINED3DTEXF_NONE ] . mip [ WINED3DTEXF_POINT ] = GL_LINEAR ;
minMipLookup [ WINED3DTEXF_NONE ] . mip [ WINED3DTEXF_LINEAR ] = GL_LINEAR ;
minMipLookup [ WINED3DTEXF_POINT ] . mip [ WINED3DTEXF_NONE ] = GL_NEAREST ;
minMipLookup [ WINED3DTEXF_POINT ] . mip [ WINED3DTEXF_POINT ] = GL_NEAREST_MIPMAP_NEAREST ;
minMipLookup [ WINED3DTEXF_POINT ] . mip [ WINED3DTEXF_LINEAR ] = GL_NEAREST_MIPMAP_LINEAR ;
minMipLookup [ WINED3DTEXF_LINEAR ] . mip [ WINED3DTEXF_NONE ] = GL_LINEAR ;
minMipLookup [ WINED3DTEXF_LINEAR ] . mip [ WINED3DTEXF_POINT ] = GL_LINEAR_MIPMAP_NEAREST ;
minMipLookup [ WINED3DTEXF_LINEAR ] . mip [ WINED3DTEXF_LINEAR ] = GL_LINEAR_MIPMAP_LINEAR ;
minMipLookup [ WINED3DTEXF_ANISOTROPIC ] . mip [ WINED3DTEXF_NONE ]
= gl_info - > supported [ EXT_TEXTURE_FILTER_ANISOTROPIC ] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR ;
minMipLookup [ WINED3DTEXF_ANISOTROPIC ] . mip [ WINED3DTEXF_POINT ]
= gl_info - > supported [ EXT_TEXTURE_FILTER_ANISOTROPIC ] ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR ;
minMipLookup [ WINED3DTEXF_ANISOTROPIC ] . mip [ WINED3DTEXF_LINEAR ]
= gl_info - > supported [ EXT_TEXTURE_FILTER_ANISOTROPIC ] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR ;
2005-08-03 13:00:28 +02:00
/* TODO: config lookups */
2007-08-08 03:09:38 +02:00
/* Make sure there's an active HDC else the WGL extensions will fail */
2007-08-16 15:04:47 +02:00
hdc = pwglGetCurrentDC ( ) ;
2007-08-08 03:09:38 +02:00
if ( hdc ) {
2009-03-29 22:08:42 +02:00
/* Not all GL drivers might offer WGL extensions e.g. VirtualBox */
if ( GL_EXTCALL ( wglGetExtensionsStringARB ) )
WGL_Extensions = GL_EXTCALL ( wglGetExtensionsStringARB ( hdc ) ) ;
2005-07-13 16:15:54 +02:00
2007-08-08 03:09:38 +02:00
if ( NULL = = WGL_Extensions ) {
ERR ( " WGL_Extensions returns NULL \n " ) ;
2004-09-29 23:26:47 +02:00
} else {
2009-03-29 22:08:42 +02:00
TRACE_ ( d3d_caps ) ( " WGL_Extensions reported: \n " ) ;
2007-08-08 03:09:38 +02:00
while ( * WGL_Extensions ! = 0x00 ) {
2007-08-08 18:57:39 +02:00
const char * Start ;
2004-09-29 23:26:47 +02:00
char ThisExtn [ 256 ] ;
2007-08-08 18:57:39 +02:00
size_t len ;
2005-07-13 16:15:54 +02:00
2007-08-08 18:57:39 +02:00
while ( isspace ( * WGL_Extensions ) ) WGL_Extensions + + ;
Start = WGL_Extensions ;
while ( ! isspace ( * WGL_Extensions ) & & * WGL_Extensions ! = 0x00 ) {
2007-08-08 03:09:38 +02:00
WGL_Extensions + + ;
2004-09-29 23:26:47 +02:00
}
2007-08-08 18:57:39 +02:00
len = WGL_Extensions - Start ;
if ( len = = 0 | | len > = sizeof ( ThisExtn ) )
continue ;
memcpy ( ThisExtn , Start , len ) ;
ThisExtn [ len ] = ' \0 ' ;
2004-09-29 23:26:47 +02:00
TRACE_ ( d3d_caps ) ( " - %s \n " , ThisExtn ) ;
2007-08-08 03:09:38 +02:00
2007-08-08 18:57:39 +02:00
if ( ! strcmp ( ThisExtn , " WGL_ARB_pbuffer " ) ) {
2007-08-08 03:09:38 +02:00
gl_info - > supported [ WGL_ARB_PBUFFER ] = TRUE ;
TRACE_ ( d3d_caps ) ( " FOUND: WGL_ARB_pbuffer support \n " ) ;
2007-06-03 13:20:27 +02:00
}
2009-03-15 10:01:43 +01:00
if ( ! strcmp ( ThisExtn , " WGL_ARB_pixel_format " ) ) {
gl_info - > supported [ WGL_ARB_PIXEL_FORMAT ] = TRUE ;
TRACE_ ( d3d_caps ) ( " FOUND: WGL_ARB_pixel_format support \n " ) ;
}
2008-04-23 00:15:15 +02:00
if ( ! strcmp ( ThisExtn , " WGL_WINE_pixel_format_passthrough " ) ) {
gl_info - > supported [ WGL_WINE_PIXEL_FORMAT_PASSTHROUGH ] = TRUE ;
TRACE_ ( d3d_caps ) ( " FOUND: WGL_WINE_pixel_format_passthrough support \n " ) ;
}
2004-09-29 23:26:47 +02:00
}
}
}
2007-09-29 16:38:11 +02:00
LEAVE_GL ( ) ;
2004-09-29 23:26:47 +02:00
2006-11-23 19:58:41 +01:00
return return_value ;
2004-09-29 23:26:47 +02:00
}
/**********************************************************
* IWineD3D implementation follows
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-06-10 13:15:32 +02:00
static UINT WINAPI IWineD3DImpl_GetAdapterCount ( IWineD3D * iface ) {
2004-09-23 06:34:27 +02:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
2009-03-11 10:15:09 +01:00
TRACE_ ( d3d_caps ) ( " (%p): Reporting %u adapters \n " , This , This - > adapter_count ) ;
return This - > adapter_count ;
2004-09-23 06:34:27 +02:00
}
2006-06-10 13:15:32 +02:00
static HRESULT WINAPI IWineD3DImpl_RegisterSoftwareDevice ( IWineD3D * iface , void * pInitializeFunction ) {
2004-09-28 04:12:12 +02:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
FIXME ( " (%p)->(%p): stub \n " , This , pInitializeFunction ) ;
2006-04-07 12:51:12 +02:00
return WINED3D_OK ;
2004-09-28 04:12:12 +02:00
}
2006-06-10 13:15:32 +02:00
static HMONITOR WINAPI IWineD3DImpl_GetAdapterMonitor ( IWineD3D * iface , UINT Adapter ) {
2004-09-28 04:12:12 +02:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
2006-07-11 04:32:47 +02:00
2008-08-24 23:43:26 +02:00
TRACE_ ( d3d_caps ) ( " (%p)->(%d) \n " , This , Adapter ) ;
2004-09-28 04:12:12 +02:00
if ( Adapter > = IWineD3DImpl_GetAdapterCount ( iface ) ) {
return NULL ;
}
2006-07-11 04:32:47 +02:00
2009-03-11 10:15:09 +01:00
return MonitorFromPoint ( This - > adapters [ Adapter ] . monitorPoint , MONITOR_DEFAULTTOPRIMARY ) ;
2004-09-28 04:12:12 +02:00
}
2005-07-13 16:15:54 +02:00
/* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
2004-09-28 04:12:12 +02:00
of the same bpp but different resolutions */
2006-10-11 03:51:13 +02:00
/* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2006-06-10 13:15:32 +02:00
static UINT WINAPI IWineD3DImpl_GetAdapterModeCount ( IWineD3D * iface , UINT Adapter , WINED3DFORMAT Format ) {
2004-09-28 04:12:12 +02:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
TRACE_ ( d3d_caps ) ( " (%p}->(Adapter: %d, Format: %s) \n " , This , Adapter , debug_d3dformat ( Format ) ) ;
if ( Adapter > = IWineD3D_GetAdapterCount ( iface ) ) {
return 0 ;
}
2007-06-09 14:27:41 +02:00
/* TODO: Store modes per adapter and read it from the adapter structure */
2004-09-28 04:12:12 +02:00
if ( Adapter = = 0 ) { /* Display */
int i = 0 ;
int j = 0 ;
2007-02-23 09:27:42 +01:00
if ( ! DEBUG_SINGLE_MODE ) {
DEVMODEW DevModeW ;
2007-08-05 19:50:45 +02:00
ZeroMemory ( & DevModeW , sizeof ( DevModeW ) ) ;
DevModeW . dmSize = sizeof ( DevModeW ) ;
2007-02-23 09:27:42 +01:00
while ( EnumDisplaySettingsExW ( NULL , j , & DevModeW , 0 ) ) {
j + + ;
switch ( Format )
{
case WINED3DFMT_UNKNOWN :
2007-04-13 16:38:10 +02:00
/* This is for D3D8, do not enumerate P8 here */
2007-02-23 09:27:42 +01:00
if ( DevModeW . dmBitsPerPel = = 32 | |
DevModeW . dmBitsPerPel = = 16 ) i + + ;
break ;
case WINED3DFMT_X8R8G8B8 :
if ( DevModeW . dmBitsPerPel = = 32 ) i + + ;
break ;
case WINED3DFMT_R5G6B5 :
if ( DevModeW . dmBitsPerPel = = 16 ) i + + ;
break ;
2007-04-13 16:38:10 +02:00
case WINED3DFMT_P8 :
if ( DevModeW . dmBitsPerPel = = 8 ) i + + ;
break ;
2007-02-23 09:27:42 +01:00
default :
/* Skip other modes as they do not match the requested format */
break ;
}
2004-09-28 04:12:12 +02:00
}
2007-02-23 09:27:42 +01:00
} else {
i = 1 ;
j = 1 ;
2004-09-28 04:12:12 +02:00
}
2007-02-23 09:27:42 +01:00
2004-09-28 04:12:12 +02:00
TRACE_ ( d3d_caps ) ( " (%p}->(Adapter: %d) => %d (out of %d) \n " , This , Adapter , i , j ) ;
return i ;
} else {
FIXME_ ( d3d_caps ) ( " Adapter not primary display \n " ) ;
}
return 0 ;
}
2006-10-11 03:51:13 +02:00
/* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2006-06-10 13:15:32 +02:00
static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes ( IWineD3D * iface , UINT Adapter , WINED3DFORMAT Format , UINT Mode , WINED3DDISPLAYMODE * pMode ) {
2004-09-28 04:12:12 +02:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
TRACE_ ( d3d_caps ) ( " (%p}->(Adapter:%d, mode:%d, pMode:%p, format:%s) \n " , This , Adapter , Mode , pMode , debug_d3dformat ( Format ) ) ;
/* Validate the parameters as much as possible */
2005-07-13 16:15:54 +02:00
if ( NULL = = pMode | |
2004-09-28 04:12:12 +02:00
Adapter > = IWineD3DImpl_GetAdapterCount ( iface ) | |
Mode > = IWineD3DImpl_GetAdapterModeCount ( iface , Adapter , Format ) ) {
2006-04-07 12:51:12 +02:00
return WINED3DERR_INVALIDCALL ;
2004-09-28 04:12:12 +02:00
}
2007-06-09 14:27:41 +02:00
/* TODO: Store modes per adapter and read it from the adapter structure */
2007-02-23 09:27:42 +01:00
if ( Adapter = = 0 & & ! DEBUG_SINGLE_MODE ) { /* Display */
2004-09-28 04:12:12 +02:00
DEVMODEW DevModeW ;
int ModeIdx = 0 ;
2008-11-26 21:37:28 +01:00
UINT i = 0 ;
2006-12-20 13:44:08 +01:00
int j = 0 ;
2005-07-13 16:15:54 +02:00
2007-08-05 19:50:45 +02:00
ZeroMemory ( & DevModeW , sizeof ( DevModeW ) ) ;
DevModeW . dmSize = sizeof ( DevModeW ) ;
2006-12-20 13:44:08 +01:00
/* If we are filtering to a specific format (D3D9), then need to skip
all unrelated modes , but if mode is irrelevant ( D3D8 ) , then we can
just count through the ones with valid bit depths */
while ( ( i < = Mode ) & & EnumDisplaySettingsExW ( NULL , j + + , & DevModeW , 0 ) ) {
switch ( Format )
{
2006-10-11 03:51:13 +02:00
case WINED3DFMT_UNKNOWN :
2007-04-13 16:38:10 +02:00
/* This is D3D8. Do not enumerate P8 here */
2006-12-20 13:44:08 +01:00
if ( DevModeW . dmBitsPerPel = = 32 | |
DevModeW . dmBitsPerPel = = 16 ) i + + ;
break ;
2006-10-11 03:51:13 +02:00
case WINED3DFMT_X8R8G8B8 :
2006-12-20 13:44:08 +01:00
if ( DevModeW . dmBitsPerPel = = 32 ) i + + ;
break ;
2006-10-11 03:51:13 +02:00
case WINED3DFMT_R5G6B5 :
2006-12-20 13:44:08 +01:00
if ( DevModeW . dmBitsPerPel = = 16 ) i + + ;
break ;
2007-04-13 16:38:10 +02:00
case WINED3DFMT_P8 :
if ( DevModeW . dmBitsPerPel = = 8 ) i + + ;
break ;
2004-09-28 04:12:12 +02:00
default :
2006-12-20 13:44:08 +01:00
/* Modes that don't match what we support can get an early-out */
TRACE_ ( d3d_caps ) ( " Searching for %s, returning D3DERR_INVALIDCALL \n " , debug_d3dformat ( Format ) ) ;
return WINED3DERR_INVALIDCALL ;
2004-09-28 04:12:12 +02:00
}
}
2006-12-20 13:44:08 +01:00
if ( i = = 0 ) {
TRACE_ ( d3d_caps ) ( " No modes found for format (%x - %s) \n " , Format , debug_d3dformat ( Format ) ) ;
return WINED3DERR_INVALIDCALL ;
}
ModeIdx = j - 1 ;
2004-09-28 04:12:12 +02:00
/* Now get the display mode via the calculated index */
2006-12-20 13:44:08 +01:00
if ( EnumDisplaySettingsExW ( NULL , ModeIdx , & DevModeW , 0 ) ) {
2004-09-28 04:12:12 +02:00
pMode - > Width = DevModeW . dmPelsWidth ;
pMode - > Height = DevModeW . dmPelsHeight ;
2007-02-15 22:37:01 +01:00
pMode - > RefreshRate = WINED3DADAPTER_DEFAULT ;
2005-09-19 17:25:07 +02:00
if ( DevModeW . dmFields & DM_DISPLAYFREQUENCY )
2004-09-28 04:12:12 +02:00
pMode - > RefreshRate = DevModeW . dmDisplayFrequency ;
2007-11-30 16:29:49 +01:00
if ( Format = = WINED3DFMT_UNKNOWN ) {
pMode - > Format = pixelformat_for_depth ( DevModeW . dmBitsPerPel ) ;
2004-09-28 04:12:12 +02:00
} else {
pMode - > Format = Format ;
}
2006-12-20 13:44:08 +01:00
} else {
2004-09-28 04:12:12 +02:00
TRACE_ ( d3d_caps ) ( " Requested mode out of range %d \n " , Mode ) ;
2006-04-07 12:51:12 +02:00
return WINED3DERR_INVALIDCALL ;
2004-09-28 04:12:12 +02:00
}
2007-02-23 09:27:42 +01:00
TRACE_ ( d3d_caps ) ( " W %d H %d rr %d fmt (%x - %s) bpp %u \n " , pMode - > Width , pMode - > Height ,
pMode - > RefreshRate , pMode - > Format , debug_d3dformat ( pMode - > Format ) ,
DevModeW . dmBitsPerPel ) ;
} else if ( DEBUG_SINGLE_MODE ) {
2004-09-28 04:12:12 +02:00
/* Return one setting of the format requested */
2006-04-07 12:51:12 +02:00
if ( Mode > 0 ) return WINED3DERR_INVALIDCALL ;
2004-09-28 04:12:12 +02:00
pMode - > Width = 800 ;
pMode - > Height = 600 ;
2007-02-23 09:27:42 +01:00
pMode - > RefreshRate = 60 ;
2006-12-20 13:44:08 +01:00
pMode - > Format = ( Format = = WINED3DFMT_UNKNOWN ) ? WINED3DFMT_X8R8G8B8 : Format ;
2004-09-28 04:12:12 +02:00
} else {
FIXME_ ( d3d_caps ) ( " Adapter not primary display \n " ) ;
}
2006-04-07 12:51:12 +02:00
return WINED3D_OK ;
2004-09-28 04:12:12 +02:00
}
2006-06-10 13:15:32 +02:00
static HRESULT WINAPI IWineD3DImpl_GetAdapterDisplayMode ( IWineD3D * iface , UINT Adapter , WINED3DDISPLAYMODE * pMode ) {
2004-09-28 04:12:12 +02:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
TRACE_ ( d3d_caps ) ( " (%p}->(Adapter: %d, pMode: %p) \n " , This , Adapter , pMode ) ;
2005-07-13 16:15:54 +02:00
if ( NULL = = pMode | |
2004-09-28 04:12:12 +02:00
Adapter > = IWineD3D_GetAdapterCount ( iface ) ) {
2006-04-07 12:51:12 +02:00
return WINED3DERR_INVALIDCALL ;
2004-09-28 04:12:12 +02:00
}
if ( Adapter = = 0 ) { /* Display */
int bpp = 0 ;
DEVMODEW DevModeW ;
2007-08-05 19:50:45 +02:00
ZeroMemory ( & DevModeW , sizeof ( DevModeW ) ) ;
DevModeW . dmSize = sizeof ( DevModeW ) ;
2007-08-06 04:42:09 +02:00
EnumDisplaySettingsExW ( NULL , ENUM_CURRENT_SETTINGS , & DevModeW , 0 ) ;
2004-09-28 04:12:12 +02:00
pMode - > Width = DevModeW . dmPelsWidth ;
pMode - > Height = DevModeW . dmPelsHeight ;
bpp = DevModeW . dmBitsPerPel ;
2007-02-15 22:37:01 +01:00
pMode - > RefreshRate = WINED3DADAPTER_DEFAULT ;
2004-09-28 04:12:12 +02:00
if ( DevModeW . dmFields & DM_DISPLAYFREQUENCY )
{
pMode - > RefreshRate = DevModeW . dmDisplayFrequency ;
}
2007-11-30 16:29:49 +01:00
pMode - > Format = pixelformat_for_depth ( bpp ) ;
2004-09-28 04:12:12 +02:00
} else {
FIXME_ ( d3d_caps ) ( " Adapter not primary display \n " ) ;
}
TRACE_ ( d3d_caps ) ( " returning w:%d, h:%d, ref:%d, fmt:%s \n " , pMode - > Width ,
pMode - > Height , pMode - > RefreshRate , debug_d3dformat ( pMode - > Format ) ) ;
2006-04-07 12:51:12 +02:00
return WINED3D_OK ;
2004-09-28 04:12:12 +02:00
}
2004-09-23 06:34:27 +02:00
2005-07-10 19:48:07 +02:00
/* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
2004-09-29 23:26:47 +02:00
and fields being inserted in the middle , a new structure is used in place */
2006-06-10 13:15:32 +02:00
static HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier ( IWineD3D * iface , UINT Adapter , DWORD Flags ,
2004-09-29 23:26:47 +02:00
WINED3DADAPTER_IDENTIFIER * pIdentifier ) {
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
2006-10-01 05:20:10 +02:00
TRACE_ ( d3d_caps ) ( " (%p}->(Adapter: %d, Flags: %x, pId=%p) \n " , This , Adapter , Flags , pIdentifier ) ;
2004-09-29 23:26:47 +02:00
if ( Adapter > = IWineD3D_GetAdapterCount ( iface ) ) {
2006-04-07 12:51:12 +02:00
return WINED3DERR_INVALIDCALL ;
2004-09-29 23:26:47 +02:00
}
2007-06-09 14:27:41 +02:00
/* Return the information requested */
TRACE_ ( d3d_caps ) ( " device/Vendor Name and Version detection using FillGLCaps \n " ) ;
2009-03-11 10:15:09 +01:00
strcpy ( pIdentifier - > Driver , This - > adapters [ Adapter ] . driver ) ;
strcpy ( pIdentifier - > Description , This - > adapters [ Adapter ] . description ) ;
2007-06-09 14:27:41 +02:00
/* Note dx8 doesn't supply a DeviceName */
if ( NULL ! = pIdentifier - > DeviceName ) strcpy ( pIdentifier - > DeviceName , " \\ \\ . \\ DISPLAY " ) ; /* FIXME: May depend on desktop? */
2009-03-11 10:15:09 +01:00
pIdentifier - > DriverVersion - > u . HighPart = This - > adapters [ Adapter ] . gl_info . driver_version_hipart ;
pIdentifier - > DriverVersion - > u . LowPart = This - > adapters [ Adapter ] . gl_info . driver_version ;
* ( pIdentifier - > VendorId ) = This - > adapters [ Adapter ] . gl_info . gl_vendor ;
* ( pIdentifier - > DeviceId ) = This - > adapters [ Adapter ] . gl_info . gl_card ;
2007-06-09 14:27:41 +02:00
* ( pIdentifier - > SubSysId ) = 0 ;
* ( pIdentifier - > Revision ) = 0 ;
2008-03-13 15:14:00 +01:00
* pIdentifier - > DeviceIdentifier = IID_D3DDEVICE_D3DUID ;
2007-06-09 14:27:41 +02:00
2008-11-23 22:33:29 +01:00
if ( wined3d_settings . pci_device_id ! = PCI_DEVICE_NONE )
{
TRACE_ ( d3d_caps ) ( " Overriding pci device id with: %x \n " , wined3d_settings . pci_device_id ) ;
* ( pIdentifier - > DeviceId ) = wined3d_settings . pci_device_id ;
}
2008-11-23 22:51:03 +01:00
if ( wined3d_settings . pci_vendor_id ! = PCI_VENDOR_NONE )
{
TRACE_ ( d3d_caps ) ( " Overriding pci vendor id with: %x \n " , wined3d_settings . pci_vendor_id ) ;
* ( pIdentifier - > VendorId ) = wined3d_settings . pci_vendor_id ;
}
2007-06-09 14:27:41 +02:00
if ( Flags & WINED3DENUM_NO_WHQL_LEVEL ) {
* ( pIdentifier - > WHQLLevel ) = 0 ;
2004-09-29 23:26:47 +02:00
} else {
2007-06-09 14:27:41 +02:00
* ( pIdentifier - > WHQLLevel ) = 1 ;
2004-09-29 23:26:47 +02:00
}
2006-04-07 12:51:12 +02:00
return WINED3D_OK ;
2004-09-29 23:26:47 +02:00
}
2009-03-13 10:44:18 +01:00
static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt ( const WineD3D_GL_Info * gl_info ,
2009-03-24 10:09:23 +01:00
const WineD3D_PixelFormat * cfg , const struct GlPixelFormatDesc * format_desc )
2009-03-13 10:44:18 +01:00
{
2007-08-11 16:25:58 +02:00
short redSize , greenSize , blueSize , alphaSize , colorBits ;
if ( ! cfg )
return FALSE ;
2008-03-21 14:52:15 +01:00
if ( cfg - > iPixelType = = WGL_TYPE_RGBA_ARB ) { /* Integer RGBA formats */
2009-03-24 10:09:24 +01:00
if ( ! getColorBits ( format_desc , & redSize , & greenSize , & blueSize , & alphaSize , & colorBits ) )
2009-03-13 10:44:18 +01:00
{
2009-03-24 10:09:23 +01:00
ERR ( " Unable to check compatibility for Format=%s \n " , debug_d3dformat ( format_desc - > format ) ) ;
2008-03-21 14:52:15 +01:00
return FALSE ;
}
2007-08-11 16:25:58 +02:00
2008-03-21 14:52:15 +01:00
if ( cfg - > redSize < redSize )
return FALSE ;
2007-08-11 16:25:58 +02:00
2008-03-21 14:52:15 +01:00
if ( cfg - > greenSize < greenSize )
return FALSE ;
2007-08-11 16:25:58 +02:00
2008-03-21 14:52:15 +01:00
if ( cfg - > blueSize < blueSize )
return FALSE ;
2007-08-11 16:25:58 +02:00
2008-03-21 14:52:15 +01:00
if ( cfg - > alphaSize < alphaSize )
return FALSE ;
return TRUE ;
} else if ( cfg - > iPixelType = = WGL_TYPE_RGBA_FLOAT_ARB ) { /* Float RGBA formats; TODO: WGL_NV_float_buffer */
2009-03-24 10:09:23 +01:00
if ( format_desc - > format = = WINED3DFMT_R16_FLOAT )
2008-03-21 14:52:15 +01:00
return ( cfg - > redSize = = 16 & & cfg - > greenSize = = 0 & & cfg - > blueSize = = 0 & & cfg - > alphaSize = = 0 ) ;
2009-03-24 10:09:23 +01:00
if ( format_desc - > format = = WINED3DFMT_R16G16_FLOAT )
2008-03-21 14:52:15 +01:00
return ( cfg - > redSize = = 16 & & cfg - > greenSize = = 16 & & cfg - > blueSize = = 0 & & cfg - > alphaSize = = 0 ) ;
2009-03-24 10:09:23 +01:00
if ( format_desc - > format = = WINED3DFMT_R16G16B16A16_FLOAT )
2008-03-21 14:52:15 +01:00
return ( cfg - > redSize = = 16 & & cfg - > greenSize = = 16 & & cfg - > blueSize = = 16 & & cfg - > alphaSize = = 16 ) ;
2009-03-24 10:09:23 +01:00
if ( format_desc - > format = = WINED3DFMT_R32_FLOAT )
2008-03-21 14:52:15 +01:00
return ( cfg - > redSize = = 32 & & cfg - > greenSize = = 0 & & cfg - > blueSize = = 0 & & cfg - > alphaSize = = 0 ) ;
2009-03-24 10:09:23 +01:00
if ( format_desc - > format = = WINED3DFMT_R32G32_FLOAT )
2008-03-21 14:52:15 +01:00
return ( cfg - > redSize = = 32 & & cfg - > greenSize = = 32 & & cfg - > blueSize = = 0 & & cfg - > alphaSize = = 0 ) ;
2009-03-24 10:09:23 +01:00
if ( format_desc - > format = = WINED3DFMT_R32G32B32A32_FLOAT )
2008-03-21 14:52:15 +01:00
return ( cfg - > redSize = = 32 & & cfg - > greenSize = = 32 & & cfg - > blueSize = = 32 & & cfg - > alphaSize = = 32 ) ;
} else {
/* Probably a color index mode */
2007-08-11 16:25:58 +02:00
return FALSE ;
2008-03-21 14:52:15 +01:00
}
2007-08-11 16:25:58 +02:00
2008-03-21 14:52:15 +01:00
return FALSE ;
2005-04-28 14:02:03 +02:00
}
2009-03-13 10:44:18 +01:00
static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt ( const WineD3D_GL_Info * gl_info ,
2009-03-24 10:09:23 +01:00
const WineD3D_PixelFormat * cfg , const struct GlPixelFormatDesc * format_desc )
2009-03-13 10:44:18 +01:00
{
2007-08-11 16:25:58 +02:00
short depthSize , stencilSize ;
2008-03-25 11:02:20 +01:00
BOOL lockable = FALSE ;
2007-08-11 16:25:58 +02:00
if ( ! cfg )
return FALSE ;
2009-03-24 10:09:24 +01:00
if ( ! getDepthStencilBits ( format_desc , & depthSize , & stencilSize ) )
2009-03-13 10:44:18 +01:00
{
2009-03-24 10:09:23 +01:00
ERR ( " Unable to check compatibility for Format=%s \n " , debug_d3dformat ( format_desc - > format ) ) ;
2007-08-11 16:25:58 +02:00
return FALSE ;
}
2009-03-24 10:09:23 +01:00
if ( ( format_desc - > format = = WINED3DFMT_D16_LOCKABLE ) | | ( format_desc - > format = = WINED3DFMT_D32F_LOCKABLE ) )
2008-03-25 11:02:20 +01:00
lockable = TRUE ;
/* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports.
* We can safely report ' compatible ' formats ( e . g . D24 can be used for D16 ) as long as we aren ' t dealing with
* a lockable format . This also helps D3D < = 7 as they expect D16 which isn ' t offered without this on Geforce8 cards . */
if ( ! ( cfg - > depthSize = = depthSize | | ( ! lockable & & cfg - > depthSize > depthSize ) ) )
2007-08-11 16:25:58 +02:00
return FALSE ;
2008-05-03 16:37:09 +02:00
/* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
* allow more stencil bits than requested . */
if ( cfg - > stencilSize < stencilSize )
2007-08-11 16:25:58 +02:00
return FALSE ;
2005-10-04 17:50:57 +02:00
return TRUE ;
2005-04-28 14:02:03 +02:00
}
2006-06-10 13:15:32 +02:00
static HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch ( IWineD3D * iface , UINT Adapter , WINED3DDEVTYPE DeviceType ,
2005-07-13 16:15:54 +02:00
WINED3DFORMAT AdapterFormat ,
WINED3DFORMAT RenderTargetFormat ,
WINED3DFORMAT DepthStencilFormat ) {
2004-10-05 04:14:06 +02:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
2007-08-11 16:25:58 +02:00
int nCfgs ;
2008-11-28 15:30:11 +01:00
const WineD3D_PixelFormat * cfgs ;
2009-03-13 10:44:18 +01:00
const struct WineD3DAdapter * adapter ;
2009-03-24 10:09:23 +01:00
const struct GlPixelFormatDesc * rt_format_desc ;
const struct GlPixelFormatDesc * ds_format_desc ;
2005-09-19 16:31:21 +02:00
int it ;
2005-07-13 16:15:54 +02:00
WARN_ ( d3d_caps ) ( " (%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s)) \n " ,
This , Adapter ,
2004-10-05 04:14:06 +02:00
DeviceType , debug_d3ddevicetype ( DeviceType ) ,
AdapterFormat , debug_d3dformat ( AdapterFormat ) ,
2005-07-13 16:15:54 +02:00
RenderTargetFormat , debug_d3dformat ( RenderTargetFormat ) ,
2004-10-05 04:14:06 +02:00
DepthStencilFormat , debug_d3dformat ( DepthStencilFormat ) ) ;
if ( Adapter > = IWineD3D_GetAdapterCount ( iface ) ) {
2006-04-07 12:51:12 +02:00
TRACE ( " (%p) Failed: Atapter (%u) higher than supported adapters (%u) returning WINED3DERR_INVALIDCALL \n " , This , Adapter , IWineD3D_GetAdapterCount ( iface ) ) ;
return WINED3DERR_INVALIDCALL ;
2004-10-05 04:14:06 +02:00
}
2005-09-19 16:31:21 +02:00
2009-03-13 10:44:18 +01:00
adapter = & This - > adapters [ Adapter ] ;
2009-03-24 10:09:23 +01:00
rt_format_desc = getFormatDescEntry ( RenderTargetFormat , & adapter - > gl_info ) ;
ds_format_desc = getFormatDescEntry ( DepthStencilFormat , & adapter - > gl_info ) ;
2009-03-13 10:44:18 +01:00
cfgs = adapter - > cfgs ;
nCfgs = adapter - > nCfgs ;
2007-08-11 16:25:58 +02:00
for ( it = 0 ; it < nCfgs ; + + it ) {
2009-03-24 10:09:23 +01:00
if ( IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt ( & adapter - > gl_info , & cfgs [ it ] , rt_format_desc ) )
2009-03-13 10:44:18 +01:00
{
2009-03-24 10:09:23 +01:00
if ( IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt ( & adapter - > gl_info , & cfgs [ it ] , ds_format_desc ) )
2009-03-13 10:44:18 +01:00
{
2007-06-08 14:16:37 +02:00
TRACE_ ( d3d_caps ) ( " (%p) : Formats matched \n " , This ) ;
return WINED3D_OK ;
2005-07-13 16:15:54 +02:00
}
}
2005-09-19 16:31:21 +02:00
}
2007-06-08 14:16:37 +02:00
WARN_ ( d3d_caps ) ( " unsupported format pair: %s and %s \n " , debug_d3dformat ( RenderTargetFormat ) , debug_d3dformat ( DepthStencilFormat ) ) ;
2005-07-13 16:15:54 +02:00
2007-06-08 14:16:37 +02:00
return WINED3DERR_NOTAVAILABLE ;
2004-10-05 04:14:06 +02:00
}
2006-06-10 13:15:32 +02:00
static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType ( IWineD3D * iface , UINT Adapter , WINED3DDEVTYPE DeviceType ,
2005-07-13 16:15:54 +02:00
WINED3DFORMAT SurfaceFormat ,
2006-03-24 17:34:26 +01:00
BOOL Windowed , WINED3DMULTISAMPLE_TYPE MultiSampleType , DWORD * pQualityLevels ) {
2005-07-13 16:15:54 +02:00
2004-10-05 04:14:06 +02:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
2008-12-03 14:53:42 +01:00
const struct GlPixelFormatDesc * glDesc ;
2009-03-13 10:44:18 +01:00
const struct WineD3DAdapter * adapter ;
2008-04-28 23:44:21 +02:00
TRACE_ ( d3d_caps ) ( " (%p)-> (Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x, pQual:%p) \n " ,
2005-07-13 16:15:54 +02:00
This ,
Adapter ,
2004-10-05 04:14:06 +02:00
DeviceType , debug_d3ddevicetype ( DeviceType ) ,
SurfaceFormat , debug_d3dformat ( SurfaceFormat ) ,
2005-07-13 16:15:54 +02:00
Windowed ,
2004-10-05 04:14:06 +02:00
MultiSampleType ,
pQualityLevels ) ;
2005-07-13 16:15:54 +02:00
2004-10-05 04:14:06 +02:00
if ( Adapter > = IWineD3D_GetAdapterCount ( iface ) ) {
2006-04-07 12:51:12 +02:00
return WINED3DERR_INVALIDCALL ;
2004-10-05 04:14:06 +02:00
}
2008-04-28 23:44:21 +02:00
/* TODO: handle Windowed, add more quality levels */
if ( WINED3DMULTISAMPLE_NONE = = MultiSampleType ) return WINED3D_OK ;
2008-06-02 23:06:01 +02:00
/* By default multisampling is disabled right now as it causes issues
* on some Nvidia driver versions and it doesn ' t work well in combination
* with FBOs yet . */
if ( ! wined3d_settings . allow_multisampling )
return WINED3DERR_NOTAVAILABLE ;
2009-03-13 10:44:18 +01:00
adapter = & This - > adapters [ Adapter ] ;
glDesc = getFormatDescEntry ( SurfaceFormat , & adapter - > gl_info ) ;
if ( ! glDesc ) return WINED3DERR_INVALIDCALL ;
2008-04-28 23:44:21 +02:00
if ( glDesc - > Flags & ( WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL ) ) {
int i , nCfgs ;
2008-11-28 15:30:11 +01:00
const WineD3D_PixelFormat * cfgs ;
2008-04-28 23:44:21 +02:00
2009-03-13 10:44:18 +01:00
cfgs = adapter - > cfgs ;
nCfgs = adapter - > nCfgs ;
2008-04-28 23:44:21 +02:00
for ( i = 0 ; i < nCfgs ; i + + ) {
if ( cfgs [ i ] . numSamples ! = MultiSampleType )
continue ;
2009-03-24 10:09:23 +01:00
if ( ! IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt ( & adapter - > gl_info , & cfgs [ i ] , glDesc ) )
2008-04-28 23:44:21 +02:00
continue ;
TRACE ( " Found iPixelFormat=%d to support MultiSampleType=%d for format %s \n " , cfgs [ i ] . iPixelFormat , MultiSampleType , debug_d3dformat ( SurfaceFormat ) ) ;
if ( pQualityLevels )
* pQualityLevels = 1 ; /* Guess at a value! */
return WINED3D_OK ;
2005-07-13 16:15:54 +02:00
}
2004-10-05 04:14:06 +02:00
}
2008-04-28 23:44:21 +02:00
else if ( glDesc - > Flags & WINED3DFMT_FLAG_RENDERTARGET ) {
short redSize , greenSize , blueSize , alphaSize , colorBits ;
int i , nCfgs ;
2008-11-28 15:30:11 +01:00
const WineD3D_PixelFormat * cfgs ;
2004-10-05 04:14:06 +02:00
2009-03-24 10:09:24 +01:00
if ( ! getColorBits ( glDesc , & redSize , & greenSize , & blueSize , & alphaSize , & colorBits ) )
2009-03-13 10:44:18 +01:00
{
2008-04-28 23:44:21 +02:00
ERR ( " Unable to color bits for format %#x, can't check multisampling capability! \n " , SurfaceFormat ) ;
return WINED3DERR_NOTAVAILABLE ;
}
2009-03-13 10:44:18 +01:00
cfgs = adapter - > cfgs ;
nCfgs = adapter - > nCfgs ;
2008-04-28 23:44:21 +02:00
for ( i = 0 ; i < nCfgs ; i + + ) {
if ( cfgs [ i ] . numSamples ! = MultiSampleType )
continue ;
if ( cfgs [ i ] . redSize ! = redSize )
continue ;
if ( cfgs [ i ] . greenSize ! = greenSize )
continue ;
if ( cfgs [ i ] . blueSize ! = blueSize )
continue ;
if ( cfgs [ i ] . alphaSize ! = alphaSize )
continue ;
TRACE ( " Found iPixelFormat=%d to support MultiSampleType=%d for format %s \n " , cfgs [ i ] . iPixelFormat , MultiSampleType , debug_d3dformat ( SurfaceFormat ) ) ;
if ( pQualityLevels )
* pQualityLevels = 1 ; /* Guess at a value! */
return WINED3D_OK ;
}
}
2006-04-07 12:51:12 +02:00
return WINED3DERR_NOTAVAILABLE ;
2004-10-05 04:14:06 +02:00
}
2008-02-26 10:47:30 +01:00
static HRESULT WINAPI IWineD3DImpl_CheckDeviceType ( IWineD3D * iface , UINT Adapter , WINED3DDEVTYPE DeviceType ,
2005-07-13 16:15:54 +02:00
WINED3DFORMAT DisplayFormat , WINED3DFORMAT BackBufferFormat , BOOL Windowed ) {
2004-10-05 04:14:06 +02:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
2006-11-23 19:57:54 +01:00
HRESULT hr = WINED3DERR_NOTAVAILABLE ;
2008-02-26 10:47:30 +01:00
UINT nmodes ;
2006-11-23 19:57:54 +01:00
2005-07-13 16:15:54 +02:00
TRACE_ ( d3d_caps ) ( " (%p)-> (STUB) (Adptr:%d, CheckType:(%x,%s), DispFmt:(%x,%s), BackBuf:(%x,%s), Win?%d): stub \n " ,
This ,
Adapter ,
2008-02-26 10:47:30 +01:00
DeviceType , debug_d3ddevicetype ( DeviceType ) ,
2004-10-05 04:14:06 +02:00
DisplayFormat , debug_d3dformat ( DisplayFormat ) ,
BackBufferFormat , debug_d3dformat ( BackBufferFormat ) ,
Windowed ) ;
if ( Adapter > = IWineD3D_GetAdapterCount ( iface ) ) {
2006-11-23 19:56:31 +01:00
WARN_ ( d3d_caps ) ( " Adapter >= IWineD3D_GetAdapterCount(iface), returning WINED3DERR_INVALIDCALL \n " ) ;
2006-04-07 12:51:12 +02:00
return WINED3DERR_INVALIDCALL ;
2004-10-05 04:14:06 +02:00
}
2008-02-26 10:47:30 +01:00
/* The task of this function is to check whether a certain display / backbuffer format
* combination is available on the given adapter . In fullscreen mode microsoft specified
* that the display format shouldn ' t provide alpha and that ignoring alpha the backbuffer
* and display format should match exactly .
* In windowed mode format conversion can occur and this depends on the driver . When format
* conversion is done , this function should nevertheless fail and applications need to use
* CheckDeviceFormatConversion .
* At the moment we assume that fullscreen and windowed have the same capabilities */
/* There are only 4 display formats */
if ( ! ( ( DisplayFormat = = WINED3DFMT_R5G6B5 ) | |
( DisplayFormat = = WINED3DFMT_X1R5G5B5 ) | |
( DisplayFormat = = WINED3DFMT_X8R8G8B8 ) | |
( DisplayFormat = = WINED3DFMT_A2R10G10B10 ) ) )
{
TRACE_ ( d3d_caps ) ( " Format %s unsupported as display format \n " , debug_d3dformat ( DisplayFormat ) ) ;
return WINED3DERR_NOTAVAILABLE ;
}
/* If the requested DisplayFormat is not available, don't continue */
nmodes = IWineD3DImpl_GetAdapterModeCount ( iface , Adapter , DisplayFormat ) ;
if ( ! nmodes ) {
TRACE_ ( d3d_caps ) ( " No available modes for display format %s \n " , debug_d3dformat ( DisplayFormat ) ) ;
return WINED3DERR_NOTAVAILABLE ;
2004-10-05 04:14:06 +02:00
}
2005-04-28 14:02:03 +02:00
2008-02-26 10:47:30 +01:00
/* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbufferformat, it means 'reuse' the display format for the backbuffer */
if ( ! Windowed & & BackBufferFormat = = WINED3DFMT_UNKNOWN ) {
TRACE_ ( d3d_caps ) ( " BackBufferFormat WINED3FMT_UNKNOWN not available in Windowed mode \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
/* In FULLSCREEN mode R5G6B5 can only be mixed with backbuffer format R5G6B5 */
if ( ( DisplayFormat = = WINED3DFMT_R5G6B5 ) & & ( BackBufferFormat ! = WINED3DFMT_R5G6B5 ) ) {
TRACE_ ( d3d_caps ) ( " Unsupported display/backbuffer format combination %s/%s \n " , debug_d3dformat ( DisplayFormat ) , debug_d3dformat ( BackBufferFormat ) ) ;
return WINED3DERR_NOTAVAILABLE ;
}
/* In FULLSCREEN mode X1R5G5B5 can only be mixed with backbuffer format *1R5G5B5 */
if ( ( DisplayFormat = = WINED3DFMT_X1R5G5B5 ) & & ! ( ( BackBufferFormat = = WINED3DFMT_X1R5G5B5 ) | | ( BackBufferFormat = = WINED3DFMT_A1R5G5B5 ) ) ) {
TRACE_ ( d3d_caps ) ( " Unsupported display/backbuffer format combination %s/%s \n " , debug_d3dformat ( DisplayFormat ) , debug_d3dformat ( BackBufferFormat ) ) ;
return WINED3DERR_NOTAVAILABLE ;
}
/* In FULLSCREEN mode X8R8G8B8 can only be mixed with backbuffer format *8R8G8B8 */
if ( ( DisplayFormat = = WINED3DFMT_X8R8G8B8 ) & & ! ( ( BackBufferFormat = = WINED3DFMT_X8R8G8B8 ) | | ( BackBufferFormat = = WINED3DFMT_A8R8G8B8 ) ) ) {
TRACE_ ( d3d_caps ) ( " Unsupported display/backbuffer format combination %s/%s \n " , debug_d3dformat ( DisplayFormat ) , debug_d3dformat ( BackBufferFormat ) ) ;
return WINED3DERR_NOTAVAILABLE ;
}
/* A2R10G10B10 is only allowed in fullscreen mode and it can only be mixed with backbuffer format A2R10G10B10 */
if ( ( DisplayFormat = = WINED3DFMT_A2R10G10B10 ) & & ( ( BackBufferFormat ! = WINED3DFMT_A2R10G10B10 ) | | Windowed ) ) {
TRACE_ ( d3d_caps ) ( " Unsupported display/backbuffer format combination %s/%s \n " , debug_d3dformat ( DisplayFormat ) , debug_d3dformat ( BackBufferFormat ) ) ;
return WINED3DERR_NOTAVAILABLE ;
}
2007-08-11 16:25:58 +02:00
2008-02-26 10:47:30 +01:00
/* Use CheckDeviceFormat to see if the BackBufferFormat is usable with the given DisplayFormat */
2008-08-27 17:42:40 +02:00
hr = IWineD3DImpl_CheckDeviceFormat ( iface , Adapter , DeviceType , DisplayFormat , WINED3DUSAGE_RENDERTARGET , WINED3DRTYPE_SURFACE , BackBufferFormat , SURFACE_OPENGL ) ;
2008-02-26 10:47:30 +01:00
if ( FAILED ( hr ) )
TRACE_ ( d3d_caps ) ( " Unsupported display/backbuffer format combination %s/%s \n " , debug_d3dformat ( DisplayFormat ) , debug_d3dformat ( BackBufferFormat ) ) ;
2006-11-23 19:57:54 +01:00
return hr ;
2004-10-05 04:14:06 +02:00
}
2008-03-16 17:02:02 +01:00
2008-03-17 18:29:29 +01:00
/* Check if we support bumpmapping for a format */
2009-03-11 10:15:09 +01:00
static BOOL CheckBumpMapCapability ( struct WineD3DAdapter * adapter ,
2009-03-24 10:09:23 +01:00
WINED3DDEVTYPE DeviceType , const struct GlPixelFormatDesc * format_desc )
2008-03-17 18:29:29 +01:00
{
2008-08-07 21:51:35 +02:00
const struct fragment_pipeline * fp ;
2009-03-24 10:09:23 +01:00
switch ( format_desc - > format )
{
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R8G8_SNORM :
case WINED3DFMT_R16G16_SNORM :
2008-08-07 21:51:35 +02:00
case WINED3DFMT_L6V5U5 :
case WINED3DFMT_X8L8V8U8 :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R8G8B8A8_SNORM :
2008-12-03 14:53:43 +01:00
/* Ask the fixed function pipeline implementation if it can deal
* with the conversion . If we ' ve got a GL extension giving native
* support this will be an identity conversion . */
2009-03-11 10:15:09 +01:00
fp = select_fragment_implementation ( adapter , DeviceType ) ;
2009-03-24 10:09:23 +01:00
if ( fp - > color_fixup_supported ( format_desc - > color_fixup ) )
2008-12-03 14:53:43 +01:00
{
2008-07-28 18:41:02 +02:00
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
2008-08-07 21:51:35 +02:00
}
2008-12-03 14:53:43 +01:00
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
2008-08-07 21:51:35 +02:00
default :
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
2008-07-28 18:41:02 +02:00
}
2008-03-17 18:29:29 +01:00
}
2008-03-16 17:02:02 +01:00
/* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
2009-03-11 10:15:09 +01:00
static BOOL CheckDepthStencilCapability ( struct WineD3DAdapter * adapter ,
2009-03-24 10:09:23 +01:00
const struct GlPixelFormatDesc * display_format_desc , const struct GlPixelFormatDesc * ds_format_desc )
2008-03-16 17:02:02 +01:00
{
int it = 0 ;
2008-03-29 00:29:38 +01:00
/* Only allow depth/stencil formats */
2009-03-24 10:09:23 +01:00
if ( ! ( ds_format_desc - > Flags & ( WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL ) ) ) return FALSE ;
2008-03-16 17:02:02 +01:00
/* Walk through all WGL pixel formats to find a match */
2009-03-11 10:15:09 +01:00
for ( it = 0 ; it < adapter - > nCfgs ; + + it )
{
WineD3D_PixelFormat * cfg = & adapter - > cfgs [ it ] ;
2009-03-24 10:09:23 +01:00
if ( IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt ( & adapter - > gl_info , cfg , display_format_desc ) )
2009-03-13 10:44:18 +01:00
{
2009-03-24 10:09:23 +01:00
if ( IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt ( & adapter - > gl_info , cfg , ds_format_desc ) )
2009-03-13 10:44:18 +01:00
{
2008-03-16 17:02:02 +01:00
return TRUE ;
}
}
}
return FALSE ;
}
2009-03-24 10:09:23 +01:00
static BOOL CheckFilterCapability ( struct WineD3DAdapter * adapter , const struct GlPixelFormatDesc * format_desc )
2008-03-17 19:27:24 +01:00
{
2008-03-29 00:18:41 +01:00
/* The flags entry of a format contains the filtering capability */
2009-03-24 10:09:23 +01:00
if ( format_desc - > Flags & WINED3DFMT_FLAG_FILTERING ) return TRUE ;
2008-03-29 00:18:41 +01:00
return FALSE ;
2008-03-17 19:27:24 +01:00
}
2008-03-16 17:37:38 +01:00
/* Check the render target capabilities of a format */
2009-03-11 10:15:09 +01:00
static BOOL CheckRenderTargetCapability ( struct WineD3DAdapter * adapter ,
2009-03-24 10:09:23 +01:00
const struct GlPixelFormatDesc * adapter_format_desc , const struct GlPixelFormatDesc * check_format_desc )
2008-03-16 17:37:38 +01:00
{
/* Filter out non-RT formats */
2009-03-24 10:09:23 +01:00
if ( ! ( check_format_desc - > Flags & WINED3DFMT_FLAG_RENDERTARGET ) ) return FALSE ;
2008-03-16 17:37:38 +01:00
if ( wined3d_settings . offscreen_rendering_mode = = ORM_BACKBUFFER ) {
2009-03-11 10:15:09 +01:00
WineD3D_PixelFormat * cfgs = adapter - > cfgs ;
2008-03-16 17:37:38 +01:00
int it ;
short AdapterRed , AdapterGreen , AdapterBlue , AdapterAlpha , AdapterTotalSize ;
short CheckRed , CheckGreen , CheckBlue , CheckAlpha , CheckTotalSize ;
2009-03-24 10:09:24 +01:00
getColorBits ( adapter_format_desc , & AdapterRed , & AdapterGreen , & AdapterBlue , & AdapterAlpha , & AdapterTotalSize ) ;
getColorBits ( check_format_desc , & CheckRed , & CheckGreen , & CheckBlue , & CheckAlpha , & CheckTotalSize ) ;
2008-03-16 17:37:38 +01:00
/* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
* The format must match in RGB , alpha is allowed to be different . ( Only the backbuffer can have alpha ) */
if ( ! ( ( AdapterRed = = CheckRed ) & & ( AdapterGreen = = CheckGreen ) & & ( AdapterBlue = = CheckBlue ) ) ) {
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
}
/* Check if there is a WGL pixel format matching the requirements, the format should also be window
* drawable ( not offscreen ; e . g . Nvidia offers R5G6B5 for pbuffers even when X is running at 24 bit ) */
2009-03-11 10:15:09 +01:00
for ( it = 0 ; it < adapter - > nCfgs ; + + it )
{
2009-03-13 10:44:18 +01:00
if ( cfgs [ it ] . windowDrawable & & IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt ( & adapter - > gl_info ,
2009-03-24 10:09:23 +01:00
& cfgs [ it ] , check_format_desc ) )
2009-03-13 10:44:18 +01:00
{
2009-03-24 10:09:23 +01:00
TRACE_ ( d3d_caps ) ( " iPixelFormat=%d is compatible with CheckFormat=%s \n " ,
cfgs [ it ] . iPixelFormat , debug_d3dformat ( check_format_desc - > format ) ) ;
2008-03-16 17:37:38 +01:00
return TRUE ;
}
}
} else if ( wined3d_settings . offscreen_rendering_mode = = ORM_PBUFFER ) {
2008-04-07 13:01:02 +02:00
/* We can probably use this function in FBO mode too on some drivers to get some basic indication of the capabilities. */
2009-03-11 10:15:09 +01:00
WineD3D_PixelFormat * cfgs = adapter - > cfgs ;
2008-03-16 17:37:38 +01:00
int it ;
/* Check if there is a WGL pixel format matching the requirements, the pixel format should also be usable with pbuffers */
2009-03-11 10:15:09 +01:00
for ( it = 0 ; it < adapter - > nCfgs ; + + it )
{
2009-03-13 10:44:18 +01:00
if ( cfgs [ it ] . pbufferDrawable & & IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt ( & adapter - > gl_info ,
2009-03-24 10:09:23 +01:00
& cfgs [ it ] , check_format_desc ) )
2009-03-13 10:44:18 +01:00
{
2009-03-24 10:09:23 +01:00
TRACE_ ( d3d_caps ) ( " iPixelFormat=%d is compatible with CheckFormat=%s \n " ,
cfgs [ it ] . iPixelFormat , debug_d3dformat ( check_format_desc - > format ) ) ;
2008-03-16 17:37:38 +01:00
return TRUE ;
}
}
} else if ( wined3d_settings . offscreen_rendering_mode = = ORM_FBO ) {
/* For now return TRUE for FBOs until we have some proper checks.
* Note that this function will only be called when the format is around for texturing . */
return TRUE ;
}
return FALSE ;
}
2009-03-24 10:09:23 +01:00
static BOOL CheckSrgbReadCapability ( struct WineD3DAdapter * adapter , const struct GlPixelFormatDesc * format_desc )
2008-03-17 18:32:53 +01:00
{
2009-03-11 10:15:09 +01:00
const WineD3D_GL_Info * gl_info = & adapter - > gl_info ;
2008-03-17 18:32:53 +01:00
/* Check for supported sRGB formats (Texture loading and framebuffer) */
if ( ! GL_SUPPORT ( EXT_TEXTURE_SRGB ) ) {
TRACE_ ( d3d_caps ) ( " [FAILED] GL_EXT_texture_sRGB not supported \n " ) ;
return FALSE ;
}
2009-03-24 10:09:23 +01:00
switch ( format_desc - > format )
{
2008-03-17 18:32:53 +01:00
case WINED3DFMT_A8R8G8B8 :
case WINED3DFMT_X8R8G8B8 :
case WINED3DFMT_A4R4G4B4 :
case WINED3DFMT_L8 :
case WINED3DFMT_A8L8 :
case WINED3DFMT_DXT1 :
case WINED3DFMT_DXT2 :
case WINED3DFMT_DXT3 :
case WINED3DFMT_DXT4 :
case WINED3DFMT_DXT5 :
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
default :
2009-03-24 10:09:23 +01:00
TRACE_ ( d3d_caps ) ( " [FAILED] Gamma texture format %s not supported. \n " , debug_d3dformat ( format_desc - > format ) ) ;
2008-03-17 18:32:53 +01:00
return FALSE ;
}
return FALSE ;
}
2009-03-11 10:15:09 +01:00
static BOOL CheckSrgbWriteCapability ( struct WineD3DAdapter * adapter ,
2009-03-24 10:09:23 +01:00
WINED3DDEVTYPE DeviceType , const struct GlPixelFormatDesc * format_desc )
2008-03-21 23:45:52 +01:00
{
/* Only offer SRGB writing on X8R8G8B8/A8R8G8B8 when we use ARB or GLSL shaders as we are
* doing the color fixup in shaders .
* Note Windows drivers ( at least on the Geforce 8800 ) also offer this on R5G6B5 . */
2009-03-24 10:09:23 +01:00
if ( ( format_desc - > format = = WINED3DFMT_X8R8G8B8 ) | | ( format_desc - > format = = WINED3DFMT_A8R8G8B8 ) )
{
2008-03-21 23:45:52 +01:00
int vs_selected_mode ;
int ps_selected_mode ;
2009-03-11 10:15:09 +01:00
select_shader_mode ( & adapter - > gl_info , DeviceType , & ps_selected_mode , & vs_selected_mode ) ;
2008-03-21 23:45:52 +01:00
if ( ( ps_selected_mode = = SHADER_ARB ) | | ( ps_selected_mode = = SHADER_GLSL ) ) {
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
}
}
2009-03-24 10:09:23 +01:00
TRACE_ ( d3d_caps ) ( " [FAILED] - no SRGB writing support on format=%s \n " , debug_d3dformat ( format_desc - > format ) ) ;
2008-03-21 23:45:52 +01:00
return FALSE ;
}
2008-03-22 22:41:30 +01:00
/* Check if a format support blending in combination with pixel shaders */
2009-03-24 10:09:23 +01:00
static BOOL CheckPostPixelShaderBlendingCapability ( struct WineD3DAdapter * adapter ,
const struct GlPixelFormatDesc * format_desc )
2008-03-22 22:41:30 +01:00
{
/* The flags entry of a format contains the post pixel shader blending capability */
2009-03-24 10:09:23 +01:00
if ( format_desc - > Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING ) return TRUE ;
2008-03-22 22:41:30 +01:00
return FALSE ;
}
2009-03-24 10:09:23 +01:00
static BOOL CheckWrapAndMipCapability ( struct WineD3DAdapter * adapter , const struct GlPixelFormatDesc * format_desc )
{
2008-04-05 23:35:21 +02:00
/* OpenGL supports mipmapping on all formats basically. Wrapping is unsupported,
* but we have to report mipmapping so we cannot reject this flag . Tests show that
* windows reports WRAPANDMIP on unfilterable surfaces as well , apparently to show
* that wrapping is supported . The lack of filtering will sort out the mipmapping
* capability anyway .
*
* For now lets report this on all formats , but in the future we may want to
* restrict it to some should games need that
*/
return TRUE ;
}
2008-03-16 17:20:27 +01:00
/* Check if a texture format is supported on the given adapter */
2009-03-11 10:15:09 +01:00
static BOOL CheckTextureCapability ( struct WineD3DAdapter * adapter ,
2009-03-24 10:09:23 +01:00
WINED3DDEVTYPE DeviceType , const struct GlPixelFormatDesc * format_desc )
2008-03-16 17:20:27 +01:00
{
2009-03-11 10:15:09 +01:00
const WineD3D_GL_Info * gl_info = & adapter - > gl_info ;
2008-08-07 21:51:35 +02:00
const shader_backend_t * shader_backend ;
const struct fragment_pipeline * fp ;
2008-03-16 17:20:27 +01:00
2009-03-24 10:09:23 +01:00
switch ( format_desc - > format )
{
2008-03-16 17:20:27 +01:00
/*****
* supported : RGB ( A ) formats
*/
case WINED3DFMT_R8G8B8 : /* Enable for dx7, blacklisted for 8 and 9 above */
case WINED3DFMT_A8R8G8B8 :
case WINED3DFMT_X8R8G8B8 :
case WINED3DFMT_R5G6B5 :
case WINED3DFMT_X1R5G5B5 :
case WINED3DFMT_A1R5G5B5 :
case WINED3DFMT_A4R4G4B4 :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_A8_UNORM :
2008-03-16 17:20:27 +01:00
case WINED3DFMT_X4R4G4B4 :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R8G8B8A8_UNORM :
2008-03-16 17:20:27 +01:00
case WINED3DFMT_X8B8G8R8 :
case WINED3DFMT_A2R10G10B10 :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R10G10B10A2_UNORM :
case WINED3DFMT_R16G16_UNORM :
2008-03-16 17:20:27 +01:00
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
2008-08-19 13:57:13 +02:00
case WINED3DFMT_R3G3B2 :
TRACE_ ( d3d_caps ) ( " [FAILED] - Not supported on Windows \n " ) ;
return FALSE ;
2008-03-16 17:20:27 +01:00
/*****
* supported : Palettized
*/
case WINED3DFMT_P8 :
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
/* No Windows driver offers A8P8, so don't offer it either */
case WINED3DFMT_A8P8 :
return FALSE ;
/*****
* Supported : ( Alpha ) - Luminance
*/
case WINED3DFMT_L8 :
case WINED3DFMT_A8L8 :
case WINED3DFMT_L16 :
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
2008-08-15 13:49:20 +02:00
/* Not supported on Windows, thus disabled */
case WINED3DFMT_A4L4 :
TRACE_ ( d3d_caps ) ( " [FAILED] - not supported on windows \n " ) ;
return FALSE ;
2008-06-19 18:24:23 +02:00
/*****
* Supported : Depth / Stencil formats
*/
2008-03-16 17:20:27 +01:00
case WINED3DFMT_D16_LOCKABLE :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_D16_UNORM :
2008-03-16 17:20:27 +01:00
case WINED3DFMT_D15S1 :
case WINED3DFMT_D24X8 :
case WINED3DFMT_D24X4S4 :
case WINED3DFMT_D24S8 :
case WINED3DFMT_D24FS8 :
case WINED3DFMT_D32 :
case WINED3DFMT_D32F_LOCKABLE :
2008-06-19 18:24:23 +02:00
return TRUE ;
2008-03-16 17:20:27 +01:00
/*****
* Not supported everywhere ( depends on GL_ATI_envmap_bumpmap or
2008-08-07 21:51:35 +02:00
* GL_NV_texture_shader ) . Emulated by shaders
2008-03-16 17:20:27 +01:00
*/
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R8G8_SNORM :
2008-03-16 17:20:27 +01:00
case WINED3DFMT_X8L8V8U8 :
case WINED3DFMT_L6V5U5 :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R8G8B8A8_SNORM :
case WINED3DFMT_R16G16_SNORM :
2008-12-03 14:53:43 +01:00
/* Ask the shader backend if it can deal with the conversion. If
* we ' ve got a GL extension giving native support this will be an
* identity conversion . */
2009-03-11 10:15:09 +01:00
shader_backend = select_shader_backend ( adapter , DeviceType ) ;
2009-03-24 10:09:23 +01:00
if ( shader_backend - > shader_color_fixup_supported ( format_desc - > color_fixup ) )
2008-12-03 14:53:43 +01:00
{
2008-08-07 21:51:35 +02:00
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
2008-04-03 17:15:47 +02:00
return TRUE ;
}
2008-12-03 14:53:43 +01:00
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
2008-03-16 17:20:27 +01:00
case WINED3DFMT_DXT1 :
case WINED3DFMT_DXT2 :
case WINED3DFMT_DXT3 :
case WINED3DFMT_DXT4 :
case WINED3DFMT_DXT5 :
if ( GL_SUPPORT ( EXT_TEXTURE_COMPRESSION_S3TC ) ) {
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
}
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
/*****
* Odd formats - not supported
*/
case WINED3DFMT_VERTEXDATA :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R16_UINT :
case WINED3DFMT_R32_UINT :
case WINED3DFMT_R16G16B16A16_SNORM :
2008-08-15 15:08:29 +02:00
case WINED3DFMT_A2W10V10U10 :
2008-12-03 14:53:43 +01:00
case WINED3DFMT_W11V11U10 :
2008-03-16 17:20:27 +01:00
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ; /* Enable when implemented */
return FALSE ;
/*****
* WINED3DFMT_CxV8U8 : Not supported right now
*/
case WINED3DFMT_CxV8U8 :
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ; /* Enable when implemented */
return FALSE ;
2008-08-19 17:55:42 +02:00
/* YUV formats */
2008-03-16 17:20:27 +01:00
case WINED3DFMT_UYVY :
case WINED3DFMT_YUY2 :
2008-08-19 17:55:42 +02:00
if ( GL_SUPPORT ( APPLE_YCBCR_422 ) ) {
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
}
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
2008-03-16 17:20:27 +01:00
return FALSE ;
2008-08-25 16:25:24 +02:00
case WINED3DFMT_YV12 :
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
2008-03-16 17:20:27 +01:00
/* Not supported */
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R16G16B16A16_UNORM :
2008-03-16 17:20:27 +01:00
case WINED3DFMT_A8R3G3B2 :
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ; /* Enable when implemented */
return FALSE ;
/* Floating point formats */
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R16_FLOAT :
case WINED3DFMT_R16G16B16A16_FLOAT :
2008-06-23 00:22:29 +02:00
if ( GL_SUPPORT ( ARB_TEXTURE_FLOAT ) & & GL_SUPPORT ( ARB_HALF_FLOAT_PIXEL ) ) {
2008-03-16 17:20:27 +01:00
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
}
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R32_FLOAT :
case WINED3DFMT_R32G32B32A32_FLOAT :
2008-03-16 17:20:27 +01:00
if ( GL_SUPPORT ( ARB_TEXTURE_FLOAT ) ) {
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
}
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R16G16_FLOAT :
case WINED3DFMT_R32G32_FLOAT :
2008-12-18 23:00:02 +01:00
if ( GL_SUPPORT ( ARB_TEXTURE_RG ) ) {
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
}
2008-03-16 17:20:27 +01:00
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
/* ATI instancing hack: Although ATI cards do not support Shader Model 3.0, they support
* instancing . To query if the card supports instancing CheckDeviceFormat with the special format
* MAKEFOURCC ( ' I ' , ' N ' , ' S ' , ' T ' ) is used . Should a ( broken ) app check for this provide a proper return value .
* We can do instancing with all shader versions , but we need vertex shaders .
*
2008-03-21 22:41:59 +01:00
* Additionally applications have to set the D3DRS_POINTSIZE render state to MAKEFOURCC ( ' I ' , ' N ' , ' S ' , ' T ' ) once
2008-03-16 17:20:27 +01:00
* to enable instancing . WineD3D doesn ' t need that and just ignores it .
*
* With Shader Model 3.0 capable cards Instancing ' just works ' in Windows .
*/
case WINEMAKEFOURCC ( ' I ' , ' N ' , ' S ' , ' T ' ) :
TRACE ( " ATI Instancing check hack \n " ) ;
if ( GL_SUPPORT ( ARB_VERTEX_PROGRAM ) | | GL_SUPPORT ( ARB_VERTEX_SHADER ) ) {
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
}
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
/* Some weird FOURCC formats */
case WINED3DFMT_R8G8_B8G8 :
case WINED3DFMT_G8R8_G8B8 :
case WINED3DFMT_MULTI2_ARGB8 :
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
2008-07-23 17:33:10 +02:00
/* Vendor specific formats */
case WINED3DFMT_ATI2N :
2008-07-23 17:39:04 +02:00
if ( GL_SUPPORT ( ATI_TEXTURE_COMPRESSION_3DC ) | | GL_SUPPORT ( EXT_TEXTURE_COMPRESSION_RGTC ) ) {
2009-03-11 10:15:09 +01:00
shader_backend = select_shader_backend ( adapter , DeviceType ) ;
fp = select_fragment_implementation ( adapter , DeviceType ) ;
2009-03-24 10:09:23 +01:00
if ( shader_backend - > shader_color_fixup_supported ( format_desc - > color_fixup )
& & fp - > color_fixup_supported ( format_desc - > color_fixup ) )
2008-12-03 14:53:43 +01:00
{
2008-08-07 21:51:35 +02:00
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
}
2008-07-23 17:33:10 +02:00
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
}
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
2008-08-25 16:25:24 +02:00
case WINED3DFMT_NVHU :
case WINED3DFMT_NVHS :
/* These formats seem to be similar to the HILO formats in GL_NV_texture_shader. NVHU
* is said to be GL_UNSIGNED_HILO16 , NVHS GL_SIGNED_HILO16 . Rumours say that d3d computes
* a 3 rd channel similarly to D3DFMT_CxV8U8 ( So NVHS could be called D3DFMT_CxV16U16 ) .
* ATI refused to support formats which can easilly be emulated with pixel shaders , so
* Applications have to deal with not having NVHS and NVHU .
*/
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
2008-03-16 17:20:27 +01:00
case WINED3DFMT_UNKNOWN :
return FALSE ;
default :
2009-03-24 10:09:23 +01:00
ERR ( " Unhandled format=%s \n " , debug_d3dformat ( format_desc - > format ) ) ;
2008-03-16 17:20:27 +01:00
break ;
}
return FALSE ;
}
2009-03-24 10:09:23 +01:00
static BOOL CheckSurfaceCapability ( struct WineD3DAdapter * adapter , const struct GlPixelFormatDesc * adapter_format_desc ,
WINED3DDEVTYPE DeviceType , const struct GlPixelFormatDesc * check_format_desc , WINED3DSURFTYPE SurfaceType )
2009-03-11 10:15:09 +01:00
{
2008-08-07 21:51:35 +02:00
const struct blit_shader * blitter ;
2008-08-27 17:42:40 +02:00
if ( SurfaceType = = SURFACE_GDI ) {
2009-03-24 10:09:23 +01:00
switch ( check_format_desc - > format )
{
2008-08-27 17:42:40 +02:00
case WINED3DFMT_R8G8B8 :
case WINED3DFMT_A8R8G8B8 :
case WINED3DFMT_X8R8G8B8 :
case WINED3DFMT_R5G6B5 :
case WINED3DFMT_X1R5G5B5 :
case WINED3DFMT_A1R5G5B5 :
case WINED3DFMT_A4R4G4B4 :
case WINED3DFMT_R3G3B2 :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_A8_UNORM :
2008-08-27 17:42:40 +02:00
case WINED3DFMT_A8R3G3B2 :
case WINED3DFMT_X4R4G4B4 :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R10G10B10A2_UNORM :
case WINED3DFMT_R8G8B8A8_UNORM :
2008-08-27 17:42:40 +02:00
case WINED3DFMT_X8B8G8R8 :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R16G16_UNORM :
2008-08-27 17:42:40 +02:00
case WINED3DFMT_A2R10G10B10 :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R16G16B16A16_UNORM :
2008-08-27 17:42:40 +02:00
case WINED3DFMT_P8 :
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
default :
TRACE_ ( d3d_caps ) ( " [FAILED] - not available on GDI surfaces \n " ) ;
return FALSE ;
}
}
2008-08-07 21:36:55 +02:00
/* All format that are supported for textures are supported for surfaces as well */
2009-03-24 10:09:23 +01:00
if ( CheckTextureCapability ( adapter , DeviceType , check_format_desc ) ) return TRUE ;
2008-08-07 21:36:55 +02:00
/* All depth stencil formats are supported on surfaces */
2009-03-24 10:09:23 +01:00
if ( CheckDepthStencilCapability ( adapter , adapter_format_desc , check_format_desc ) ) return TRUE ;
2008-08-07 21:36:55 +02:00
2008-08-07 21:51:35 +02:00
/* If opengl can't process the format natively, the blitter may be able to convert it */
2009-03-11 10:15:09 +01:00
blitter = select_blit_implementation ( adapter , DeviceType ) ;
2009-03-24 10:09:23 +01:00
if ( blitter - > color_fixup_supported ( check_format_desc - > color_fixup ) )
2008-12-03 14:53:43 +01:00
{
2008-08-07 21:51:35 +02:00
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
}
2008-08-07 21:36:55 +02:00
/* Reject other formats */
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
}
2009-03-24 10:09:23 +01:00
static BOOL CheckVertexTextureCapability ( struct WineD3DAdapter * adapter , const struct GlPixelFormatDesc * format_desc )
2008-03-17 18:37:15 +01:00
{
2009-03-11 10:15:09 +01:00
const WineD3D_GL_Info * gl_info = & adapter - > gl_info ;
2008-03-17 18:37:15 +01:00
if ( ! GL_LIMITS ( vertex_samplers ) ) {
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
}
2009-03-24 10:09:23 +01:00
switch ( format_desc - > format )
{
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R32G32B32A32_FLOAT :
2008-03-17 18:37:15 +01:00
if ( ! GL_SUPPORT ( ARB_TEXTURE_FLOAT ) ) {
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
}
TRACE_ ( d3d_caps ) ( " [OK] \n " ) ;
return TRUE ;
default :
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return FALSE ;
}
return FALSE ;
}
2006-06-10 13:15:32 +02:00
static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat ( IWineD3D * iface , UINT Adapter , WINED3DDEVTYPE DeviceType ,
2008-08-27 17:42:40 +02:00
WINED3DFORMAT AdapterFormat , DWORD Usage , WINED3DRESOURCETYPE RType , WINED3DFORMAT CheckFormat ,
WINED3DSURFTYPE SurfaceType ) {
2004-10-05 04:14:06 +02:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
2009-03-11 10:15:09 +01:00
struct WineD3DAdapter * adapter = & This - > adapters [ Adapter ] ;
const WineD3D_GL_Info * gl_info = & adapter - > gl_info ;
2009-03-24 10:09:23 +01:00
const struct GlPixelFormatDesc * format_desc = getFormatDescEntry ( CheckFormat , gl_info ) ;
const struct GlPixelFormatDesc * adapter_format_desc = getFormatDescEntry ( AdapterFormat , gl_info ) ;
2008-03-16 17:02:02 +01:00
DWORD UsageCaps = 0 ;
2006-10-05 11:11:03 +02:00
TRACE_ ( d3d_caps ) ( " (%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), AdptFmt:(%u,%s), Use:(%u,%s,%s), ResTyp:(%x,%s), CheckFmt:(%u,%s)) \n " ,
2005-07-13 16:15:54 +02:00
This ,
Adapter ,
DeviceType , debug_d3ddevicetype ( DeviceType ) ,
AdapterFormat , debug_d3dformat ( AdapterFormat ) ,
2006-07-28 21:33:20 +02:00
Usage , debug_d3dusage ( Usage ) , debug_d3dusagequery ( Usage ) ,
2005-07-13 16:15:54 +02:00
RType , debug_d3dresourcetype ( RType ) ,
2004-10-05 04:14:06 +02:00
CheckFormat , debug_d3dformat ( CheckFormat ) ) ;
if ( Adapter > = IWineD3D_GetAdapterCount ( iface ) ) {
2006-04-07 12:51:12 +02:00
return WINED3DERR_INVALIDCALL ;
2004-10-05 04:14:06 +02:00
}
2008-03-16 17:20:27 +01:00
if ( RType = = WINED3DRTYPE_CUBETEXTURE ) {
2008-08-27 17:42:40 +02:00
if ( SurfaceType ! = SURFACE_OPENGL ) {
TRACE ( " [FAILED] \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
2008-03-16 17:20:27 +01:00
/* Cubetexture allows:
* - D3DUSAGE_AUTOGENMIPMAP
* - D3DUSAGE_DEPTHSTENCIL
* - D3DUSAGE_DYNAMIC
* - D3DUSAGE_NONSECURE ( d3d9ex )
* - D3DUSAGE_RENDERTARGET
* - D3DUSAGE_SOFTWAREPROCESSING
2008-04-05 23:35:21 +02:00
* - D3DUSAGE_QUERY_WRAPANDMIP
2008-03-16 17:20:27 +01:00
*/
if ( GL_SUPPORT ( ARB_TEXTURE_CUBE_MAP ) ) {
/* Check if the texture format is around */
2009-03-24 10:09:23 +01:00
if ( CheckTextureCapability ( adapter , DeviceType , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-17 20:11:32 +01:00
if ( Usage & WINED3DUSAGE_AUTOGENMIPMAP ) {
/* Check for automatic mipmap generation support */
if ( GL_SUPPORT ( SGIS_GENERATE_MIPMAP ) ) {
UsageCaps | = WINED3DUSAGE_AUTOGENMIPMAP ;
} else {
2008-04-22 08:18:14 +02:00
/* When autogenmipmap isn't around continue and return WINED3DOK_NOAUTOGEN instead of D3D_OK */
2008-03-17 20:11:32 +01:00
TRACE_ ( d3d_caps ) ( " [FAILED] - No autogenmipmap support, but continuing \n " ) ;
}
}
2008-03-18 09:43:27 +01:00
/* Always report dynamic locking */
if ( Usage & WINED3DUSAGE_DYNAMIC )
UsageCaps | = WINED3DUSAGE_DYNAMIC ;
2008-03-16 17:37:38 +01:00
if ( Usage & WINED3DUSAGE_RENDERTARGET ) {
2009-03-24 10:09:23 +01:00
if ( CheckRenderTargetCapability ( adapter , adapter_format_desc , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-16 17:37:38 +01:00
UsageCaps | = WINED3DUSAGE_RENDERTARGET ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No rendertarget support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:32:53 +01:00
2008-03-18 09:45:35 +01:00
/* Always report software processing */
if ( Usage & WINED3DUSAGE_SOFTWAREPROCESSING )
UsageCaps | = WINED3DUSAGE_SOFTWAREPROCESSING ;
2008-03-17 19:27:24 +01:00
/* Check QUERY_FILTER support */
if ( Usage & WINED3DUSAGE_QUERY_FILTER ) {
2009-03-24 10:09:23 +01:00
if ( CheckFilterCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-17 19:27:24 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_FILTER ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query filter support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-22 22:41:30 +01:00
/* Check QUERY_POSTPIXELSHADER_BLENDING support */
if ( Usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING ) {
2009-03-24 10:09:23 +01:00
if ( CheckPostPixelShaderBlendingCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-22 22:41:30 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query post pixelshader blending support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:32:53 +01:00
/* Check QUERY_SRGBREAD support */
if ( Usage & WINED3DUSAGE_QUERY_SRGBREAD ) {
2009-03-24 10:09:23 +01:00
if ( CheckSrgbReadCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-17 18:32:53 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_SRGBREAD ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query srgbread support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:37:15 +01:00
2008-03-21 23:45:52 +01:00
/* Check QUERY_SRGBWRITE support */
if ( Usage & WINED3DUSAGE_QUERY_SRGBWRITE ) {
2009-03-24 10:09:23 +01:00
if ( CheckSrgbWriteCapability ( adapter , DeviceType , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-21 23:45:52 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_SRGBWRITE ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query srgbwrite support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:37:15 +01:00
/* Check QUERY_VERTEXTEXTURE support */
if ( Usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE ) {
2009-03-24 10:09:23 +01:00
if ( CheckVertexTextureCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-17 18:37:15 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_VERTEXTEXTURE ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query vertextexture support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-04-05 23:35:21 +02:00
/* Check QUERY_WRAPANDMIP support */
if ( Usage & WINED3DUSAGE_QUERY_WRAPANDMIP ) {
2009-03-24 10:09:23 +01:00
if ( CheckWrapAndMipCapability ( adapter , format_desc ) )
{
2008-04-05 23:35:21 +02:00
UsageCaps | = WINED3DUSAGE_QUERY_WRAPANDMIP ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No wrapping and mipmapping support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-21 22:11:12 +01:00
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - Cube texture format not supported \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
2008-03-16 17:20:27 +01:00
}
2008-03-21 21:59:14 +01:00
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No cube texture support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
2008-03-16 17:20:27 +01:00
}
} else if ( RType = = WINED3DRTYPE_SURFACE ) {
2008-03-16 17:02:02 +01:00
/* Surface allows:
* - D3DUSAGE_DEPTHSTENCIL
* - D3DUSAGE_NONSECURE ( d3d9ex )
* - D3DUSAGE_RENDERTARGET
*/
2009-03-24 10:09:23 +01:00
if ( CheckSurfaceCapability ( adapter , adapter_format_desc , DeviceType , format_desc , SurfaceType ) )
2009-03-11 10:15:09 +01:00
{
2008-08-07 21:36:55 +02:00
if ( Usage & WINED3DUSAGE_DEPTHSTENCIL ) {
2009-03-24 10:09:23 +01:00
if ( CheckDepthStencilCapability ( adapter , adapter_format_desc , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-08-07 21:36:55 +02:00
UsageCaps | = WINED3DUSAGE_DEPTHSTENCIL ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No depthstencil support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
2008-03-16 17:02:02 +01:00
}
2008-03-16 17:37:38 +01:00
2008-08-07 21:36:55 +02:00
if ( Usage & WINED3DUSAGE_RENDERTARGET ) {
2009-03-24 10:09:23 +01:00
if ( CheckRenderTargetCapability ( adapter , adapter_format_desc , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-08-07 21:36:55 +02:00
UsageCaps | = WINED3DUSAGE_RENDERTARGET ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No rendertarget support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
2008-03-16 17:37:38 +01:00
}
2008-04-03 16:14:57 +02:00
2008-08-07 21:36:55 +02:00
/* Check QUERY_POSTPIXELSHADER_BLENDING support */
if ( Usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING ) {
2009-03-24 10:09:23 +01:00
if ( CheckPostPixelShaderBlendingCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-08-07 21:36:55 +02:00
UsageCaps | = WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query post pixelshader blending support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
2008-04-03 16:14:57 +02:00
}
2008-08-07 21:36:55 +02:00
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - Not supported for plain surfaces \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
2008-04-03 16:14:57 +02:00
}
2008-08-07 21:36:55 +02:00
2008-03-16 17:02:02 +01:00
} else if ( RType = = WINED3DRTYPE_TEXTURE ) {
/* Texture allows:
* - D3DUSAGE_AUTOGENMIPMAP
* - D3DUSAGE_DEPTHSTENCIL
* - D3DUSAGE_DMAP
* - D3DUSAGE_DYNAMIC
* - D3DUSAGE_NONSECURE ( d3d9ex )
* - D3DUSAGE_RENDERTARGET
* - D3DUSAGE_SOFTWAREPROCESSING
* - D3DUSAGE_TEXTAPI ( d3d9ex )
2008-04-05 23:35:21 +02:00
* - D3DUSAGE_QUERY_WRAPANDMIP
2008-03-16 17:02:02 +01:00
*/
2008-08-27 17:42:40 +02:00
if ( SurfaceType ! = SURFACE_OPENGL ) {
TRACE ( " [FAILED] \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
2008-03-16 17:20:27 +01:00
/* Check if the texture format is around */
2009-03-24 10:09:23 +01:00
if ( CheckTextureCapability ( adapter , DeviceType , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-17 20:11:32 +01:00
if ( Usage & WINED3DUSAGE_AUTOGENMIPMAP ) {
/* Check for automatic mipmap generation support */
if ( GL_SUPPORT ( SGIS_GENERATE_MIPMAP ) ) {
UsageCaps | = WINED3DUSAGE_AUTOGENMIPMAP ;
} else {
2008-04-22 08:18:14 +02:00
/* When autogenmipmap isn't around continue and return WINED3DOK_NOAUTOGEN instead of D3D_OK */
2008-03-17 20:11:32 +01:00
TRACE_ ( d3d_caps ) ( " [FAILED] - No autogenmipmap support, but continuing \n " ) ;
}
}
2008-03-18 09:43:27 +01:00
/* Always report dynamic locking */
if ( Usage & WINED3DUSAGE_DYNAMIC )
UsageCaps | = WINED3DUSAGE_DYNAMIC ;
2008-03-16 17:37:38 +01:00
if ( Usage & WINED3DUSAGE_RENDERTARGET ) {
2009-03-24 10:09:23 +01:00
if ( CheckRenderTargetCapability ( adapter , adapter_format_desc , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-16 17:37:38 +01:00
UsageCaps | = WINED3DUSAGE_RENDERTARGET ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No rendertarget support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:29:29 +01:00
2008-03-18 09:45:35 +01:00
/* Always report software processing */
if ( Usage & WINED3DUSAGE_SOFTWAREPROCESSING )
UsageCaps | = WINED3DUSAGE_SOFTWAREPROCESSING ;
2008-03-17 19:27:24 +01:00
/* Check QUERY_FILTER support */
if ( Usage & WINED3DUSAGE_QUERY_FILTER ) {
2009-03-24 10:09:23 +01:00
if ( CheckFilterCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-17 19:27:24 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_FILTER ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query filter support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:29:29 +01:00
/* Check QUERY_LEGACYBUMPMAP support */
if ( Usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP ) {
2009-03-24 10:09:23 +01:00
if ( CheckBumpMapCapability ( adapter , DeviceType , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-17 18:29:29 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_LEGACYBUMPMAP ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No legacy bumpmap support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:32:53 +01:00
2008-03-22 22:41:30 +01:00
/* Check QUERY_POSTPIXELSHADER_BLENDING support */
if ( Usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING ) {
2009-03-24 10:09:23 +01:00
if ( CheckPostPixelShaderBlendingCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-22 22:41:30 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query post pixelshader blending support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:32:53 +01:00
/* Check QUERY_SRGBREAD support */
if ( Usage & WINED3DUSAGE_QUERY_SRGBREAD ) {
2009-03-24 10:09:23 +01:00
if ( CheckSrgbReadCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-17 18:32:53 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_SRGBREAD ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query srgbread support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:37:15 +01:00
2008-03-21 23:45:52 +01:00
/* Check QUERY_SRGBWRITE support */
if ( Usage & WINED3DUSAGE_QUERY_SRGBWRITE ) {
2009-03-24 10:09:23 +01:00
if ( CheckSrgbWriteCapability ( adapter , DeviceType , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-21 23:45:52 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_SRGBWRITE ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query srgbwrite support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:37:15 +01:00
/* Check QUERY_VERTEXTEXTURE support */
if ( Usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE ) {
2009-03-24 10:09:23 +01:00
if ( CheckVertexTextureCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-17 18:37:15 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_VERTEXTEXTURE ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query vertextexture support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-04-05 23:35:21 +02:00
/* Check QUERY_WRAPANDMIP support */
if ( Usage & WINED3DUSAGE_QUERY_WRAPANDMIP ) {
2009-03-24 10:09:23 +01:00
if ( CheckWrapAndMipCapability ( adapter , format_desc ) )
{
2008-04-05 23:35:21 +02:00
UsageCaps | = WINED3DUSAGE_QUERY_WRAPANDMIP ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No wrapping and mipmapping support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-06-19 18:24:23 +02:00
if ( Usage & WINED3DUSAGE_DEPTHSTENCIL ) {
2009-03-24 10:09:23 +01:00
if ( CheckDepthStencilCapability ( adapter , adapter_format_desc , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-06-19 18:24:23 +02:00
UsageCaps | = WINED3DUSAGE_DEPTHSTENCIL ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No depth stencil support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-21 22:11:12 +01:00
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - Texture format not supported \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
2008-03-16 17:02:02 +01:00
}
2008-03-21 21:57:14 +01:00
} else if ( ( RType = = WINED3DRTYPE_VOLUME ) | | ( RType = = WINED3DRTYPE_VOLUMETEXTURE ) ) {
/* Volume is to VolumeTexture what Surface is to Texture but its usage caps are not documented.
* Most driver seem to offer ( nearly ) the same on Volume and VolumeTexture , so do that too .
*
* Volumetexture allows :
2008-03-18 09:43:27 +01:00
* - D3DUSAGE_DYNAMIC
* - D3DUSAGE_NONSECURE ( d3d9ex )
* - D3DUSAGE_SOFTWAREPROCESSING
2008-04-05 23:35:21 +02:00
* - D3DUSAGE_QUERY_WRAPANDMIP
2008-03-18 09:43:27 +01:00
*/
2008-08-27 17:42:40 +02:00
if ( SurfaceType ! = SURFACE_OPENGL ) {
TRACE ( " [FAILED] \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
2008-03-16 17:20:27 +01:00
/* Check volume texture and volume usage caps */
if ( GL_SUPPORT ( EXT_TEXTURE3D ) ) {
2009-03-24 10:09:23 +01:00
if ( ! CheckTextureCapability ( adapter , DeviceType , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-16 17:20:27 +01:00
TRACE_ ( d3d_caps ) ( " [FAILED] - Format not supported \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
2008-03-17 18:32:53 +01:00
2008-03-18 09:43:27 +01:00
/* Always report dynamic locking */
if ( Usage & WINED3DUSAGE_DYNAMIC )
UsageCaps | = WINED3DUSAGE_DYNAMIC ;
2008-03-18 09:45:35 +01:00
/* Always report software processing */
if ( Usage & WINED3DUSAGE_SOFTWAREPROCESSING )
UsageCaps | = WINED3DUSAGE_SOFTWAREPROCESSING ;
2008-03-17 19:27:24 +01:00
/* Check QUERY_FILTER support */
if ( Usage & WINED3DUSAGE_QUERY_FILTER ) {
2009-03-24 10:09:23 +01:00
if ( CheckFilterCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-17 19:27:24 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_FILTER ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query filter support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-22 22:41:30 +01:00
/* Check QUERY_POSTPIXELSHADER_BLENDING support */
if ( Usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING ) {
2009-03-24 10:09:23 +01:00
if ( CheckPostPixelShaderBlendingCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-22 22:41:30 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query post pixelshader blending support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:32:53 +01:00
/* Check QUERY_SRGBREAD support */
if ( Usage & WINED3DUSAGE_QUERY_SRGBREAD ) {
2009-03-24 10:09:23 +01:00
if ( CheckSrgbReadCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-17 18:32:53 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_SRGBREAD ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query srgbread support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:37:15 +01:00
2008-03-21 23:45:52 +01:00
/* Check QUERY_SRGBWRITE support */
if ( Usage & WINED3DUSAGE_QUERY_SRGBWRITE ) {
2009-03-24 10:09:23 +01:00
if ( CheckSrgbWriteCapability ( adapter , DeviceType , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-21 23:45:52 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_SRGBWRITE ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query srgbwrite support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-17 18:37:15 +01:00
/* Check QUERY_VERTEXTEXTURE support */
if ( Usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE ) {
2009-03-24 10:09:23 +01:00
if ( CheckVertexTextureCapability ( adapter , format_desc ) )
2009-03-11 10:15:09 +01:00
{
2008-03-17 18:37:15 +01:00
UsageCaps | = WINED3DUSAGE_QUERY_VERTEXTEXTURE ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No query vertextexture support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-04-05 23:35:21 +02:00
/* Check QUERY_WRAPANDMIP support */
if ( Usage & WINED3DUSAGE_QUERY_WRAPANDMIP ) {
2009-03-24 10:09:23 +01:00
if ( CheckWrapAndMipCapability ( adapter , format_desc ) )
{
2008-04-05 23:35:21 +02:00
UsageCaps | = WINED3DUSAGE_QUERY_WRAPANDMIP ;
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No wrapping and mipmapping support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
}
2008-03-21 21:53:56 +01:00
} else {
TRACE_ ( d3d_caps ) ( " [FAILED] - No volume texture support \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
2007-09-01 19:57:25 +02:00
}
2008-03-16 17:20:27 +01:00
2007-09-01 19:57:25 +02:00
/* Filter formats that need conversion; For one part, this conversion is unimplemented,
* and volume textures are huge , so it would be a big performance hit . Unless we hit an
* app needing one of those formats , don ' t advertize them to avoid leading apps into
* temptation . The windows drivers don ' t support most of those formats on volumes anyway ,
* except of R32F .
*/
switch ( CheckFormat ) {
case WINED3DFMT_P8 :
case WINED3DFMT_A4L4 :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R32_FLOAT :
case WINED3DFMT_R16_FLOAT :
2007-09-01 19:57:25 +02:00
case WINED3DFMT_X8L8V8U8 :
case WINED3DFMT_L6V5U5 :
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R16G16_UNORM :
2007-09-01 19:57:25 +02:00
TRACE_ ( d3d_caps ) ( " [FAILED] - No converted formats on volumes \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R8G8B8A8_SNORM :
case WINED3DFMT_R16G16_SNORM :
2007-09-01 19:57:25 +02:00
if ( ! GL_SUPPORT ( NV_TEXTURE_SHADER ) ) {
TRACE_ ( d3d_caps ) ( " [FAILED] - No converted formats on volumes \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
break ;
2009-02-19 16:59:42 +01:00
case WINED3DFMT_R8G8_SNORM :
2008-11-03 18:36:19 +01:00
if ( ! GL_SUPPORT ( NV_TEXTURE_SHADER ) ) {
2007-09-01 19:57:25 +02:00
TRACE_ ( d3d_caps ) ( " [FAILED] - No converted formats on volumes \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
break ;
case WINED3DFMT_DXT1 :
case WINED3DFMT_DXT2 :
case WINED3DFMT_DXT3 :
case WINED3DFMT_DXT4 :
case WINED3DFMT_DXT5 :
/* The GL_EXT_texture_compression_s3tc spec requires that loading an s3tc
* compressed texture results in an error . While the D3D refrast does
* support s3tc volumes , at least the nvidia windows driver does not , so
* we ' re free not to support this format .
*/
TRACE_ ( d3d_caps ) ( " [FAILED] - DXTn does not support 3D textures \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
default :
/* Do nothing, continue with checking the format below */
break ;
}
2008-03-21 21:50:26 +01:00
} else if ( ( RType = = WINED3DRTYPE_INDEXBUFFER ) | | ( RType = = WINED3DRTYPE_VERTEXBUFFER ) ) {
/* For instance vertexbuffer/indexbuffer aren't supported yet because no Windows drivers seem to offer it */
TRACE_ ( d3d_caps ) ( " Unhandled resource type D3DRTYPE_INDEXBUFFER / D3DRTYPE_VERTEXBUFFER \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
2008-08-27 17:42:40 +02:00
}
2007-05-01 01:27:05 +02:00
2006-07-27 00:56:09 +02:00
/* This format is nothing special and it is supported perfectly.
2006-09-07 20:01:50 +02:00
* However , ati and nvidia driver on windows do not mark this format as
* supported ( tested with the dxCapsViewer ) and pretending to
* support this format uncovers a bug in Battlefield 1942 ( fonts are missing )
2006-07-27 00:56:09 +02:00
* So do the same as Windows drivers and pretend not to support it on dx8 and 9
* Enable it on dx7 . It will need additional checking on dx10 when we support it .
*/
if ( This - > dxVersion > 7 & & CheckFormat = = WINED3DFMT_R8G8B8 ) {
TRACE_ ( d3d_caps ) ( " [FAILED] \n " ) ;
return WINED3DERR_NOTAVAILABLE ;
}
2008-03-17 20:11:32 +01:00
/* When the UsageCaps exactly matches Usage return WINED3D_OK except for the situation in which
* WINED3DUSAGE_AUTOGENMIPMAP isn ' t around , then WINED3DOK_NOAUTOGEN is returned if all the other
* usage flags match . */
if ( UsageCaps = = Usage ) {
return WINED3D_OK ;
} else if ( ( UsageCaps = = ( Usage & ~ WINED3DUSAGE_AUTOGENMIPMAP ) ) & & ( Usage & WINED3DUSAGE_AUTOGENMIPMAP ) ) {
return WINED3DOK_NOAUTOGEN ;
} else {
2008-03-23 01:00:19 +01:00
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 ) ;
2008-03-17 20:11:32 +01:00
return WINED3DERR_NOTAVAILABLE ;
}
2004-10-05 04:14:06 +02:00
}
2006-06-10 13:15:32 +02:00
static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion ( IWineD3D * iface , UINT Adapter , WINED3DDEVTYPE DeviceType ,
2005-07-13 16:15:54 +02:00
WINED3DFORMAT SourceFormat , WINED3DFORMAT TargetFormat ) {
2004-10-05 04:14:06 +02:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
2006-07-11 00:57:29 +02:00
FIXME_ ( d3d_caps ) ( " (%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), SrcFmt:(%u,%s), TgtFmt:(%u,%s)) \n " ,
2005-07-13 16:15:54 +02:00
This ,
Adapter ,
DeviceType , debug_d3ddevicetype ( DeviceType ) ,
SourceFormat , debug_d3dformat ( SourceFormat ) ,
2004-10-05 04:14:06 +02:00
TargetFormat , debug_d3dformat ( TargetFormat ) ) ;
2006-04-07 12:51:12 +02:00
return WINED3D_OK ;
2004-10-05 04:14:06 +02:00
}
2009-03-11 10:15:09 +01:00
static const shader_backend_t * select_shader_backend ( struct WineD3DAdapter * adapter , WINED3DDEVTYPE DeviceType )
{
2008-03-18 19:37:53 +01:00
const shader_backend_t * ret ;
int vs_selected_mode ;
int ps_selected_mode ;
2009-03-11 10:15:09 +01:00
select_shader_mode ( & adapter - > gl_info , DeviceType , & ps_selected_mode , & vs_selected_mode ) ;
2008-03-18 19:37:53 +01:00
if ( vs_selected_mode = = SHADER_GLSL | | ps_selected_mode = = SHADER_GLSL ) {
ret = & glsl_shader_backend ;
} else if ( vs_selected_mode = = SHADER_ARB | | ps_selected_mode = = SHADER_ARB ) {
ret = & arb_program_shader_backend ;
} else {
ret = & none_shader_backend ;
}
return ret ;
}
2009-03-11 10:15:09 +01:00
static const struct fragment_pipeline * select_fragment_implementation ( struct WineD3DAdapter * adapter ,
WINED3DDEVTYPE DeviceType )
{
const WineD3D_GL_Info * gl_info = & adapter - > gl_info ;
2008-07-04 22:01:26 +02:00
int vs_selected_mode ;
int ps_selected_mode ;
2009-03-11 10:15:09 +01:00
select_shader_mode ( & adapter - > gl_info , DeviceType , & ps_selected_mode , & vs_selected_mode ) ;
2008-07-28 18:41:02 +02:00
if ( ( ps_selected_mode = = SHADER_ARB | | ps_selected_mode = = SHADER_GLSL ) & & GL_SUPPORT ( ARB_FRAGMENT_PROGRAM ) ) {
return & arbfp_fragment_pipeline ;
} else if ( ps_selected_mode = = SHADER_ATI ) {
2008-07-04 22:09:49 +02:00
return & atifs_fragment_pipeline ;
2008-07-04 23:15:18 +02:00
} else if ( GL_SUPPORT ( NV_REGISTER_COMBINERS ) & & GL_SUPPORT ( NV_TEXTURE_SHADER2 ) ) {
return & nvts_fragment_pipeline ;
} else if ( GL_SUPPORT ( NV_REGISTER_COMBINERS ) ) {
return & nvrc_fragment_pipeline ;
} else {
return & ffp_fragment_pipeline ;
2008-07-04 22:01:26 +02:00
}
}
2009-03-11 10:15:09 +01:00
static const struct blit_shader * select_blit_implementation ( struct WineD3DAdapter * adapter , WINED3DDEVTYPE DeviceType )
{
const WineD3D_GL_Info * gl_info = & adapter - > gl_info ;
2008-08-01 20:21:10 +02:00
int vs_selected_mode ;
int ps_selected_mode ;
2009-03-11 10:15:09 +01:00
select_shader_mode ( & adapter - > gl_info , DeviceType , & ps_selected_mode , & vs_selected_mode ) ;
2008-08-19 18:09:45 +02:00
if ( ( ps_selected_mode = = SHADER_ARB | | ps_selected_mode = = SHADER_GLSL ) & & GL_SUPPORT ( ARB_FRAGMENT_PROGRAM ) ) {
return & arbfp_blit ;
} else {
return & ffp_blit ;
}
2008-08-01 20:21:10 +02:00
}
2005-07-13 16:15:54 +02:00
/* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
subset of a D3DCAPS9 structure . However , it has to come via a void *
2004-10-06 02:05:29 +02:00
as the d3d8 interface cannot import the d3d9 header */
2006-06-10 13:15:32 +02:00
static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps ( IWineD3D * iface , UINT Adapter , WINED3DDEVTYPE DeviceType , WINED3DCAPS * pCaps ) {
2004-10-06 02:05:29 +02:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
2009-03-11 10:15:09 +01:00
struct WineD3DAdapter * adapter = & This - > adapters [ Adapter ] ;
const WineD3D_GL_Info * gl_info = & adapter - > gl_info ;
2006-10-08 05:25:01 +02:00
int vs_selected_mode ;
int ps_selected_mode ;
2008-03-18 19:39:26 +01:00
struct shader_caps shader_caps ;
2008-07-03 21:36:18 +02:00
struct fragment_caps fragment_caps ;
2008-03-18 19:39:26 +01:00
const shader_backend_t * shader_backend ;
2008-07-03 21:36:18 +02:00
const struct fragment_pipeline * frag_pipeline = NULL ;
2008-07-29 18:03:59 +02:00
DWORD ckey_caps , blit_caps , fx_caps ;
2004-10-06 02:05:29 +02:00
TRACE_ ( d3d_caps ) ( " (%p)->(Adptr:%d, DevType: %x, pCaps: %p) \n " , This , Adapter , DeviceType , pCaps ) ;
if ( Adapter > = IWineD3D_GetAdapterCount ( iface ) ) {
2006-04-07 12:51:12 +02:00
return WINED3DERR_INVALIDCALL ;
2004-10-06 02:05:29 +02:00
}
2009-03-11 10:15:09 +01:00
select_shader_mode ( & adapter - > gl_info , DeviceType , & ps_selected_mode , & vs_selected_mode ) ;
2006-10-08 05:25:01 +02:00
/* This function should *not* be modifying GL caps
* TODO : move the functionality where it belongs */
2009-03-11 10:15:09 +01:00
select_shader_max_constants ( ps_selected_mode , vs_selected_mode , & adapter - > gl_info ) ;
2004-10-06 02:05:29 +02:00
/* ------------------------------------------------
The following fields apply to both d3d8 and d3d9
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2008-03-18 19:26:00 +01:00
pCaps - > DeviceType = ( DeviceType = = WINED3DDEVTYPE_HAL ) ? WINED3DDEVTYPE_HAL : WINED3DDEVTYPE_REF ; /* Not quite true, but use h/w supported by opengl I suppose */
pCaps - > AdapterOrdinal = Adapter ;
2005-06-22 20:30:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > Caps = 0 ;
pCaps - > Caps2 = WINED3DCAPS2_CANRENDERWINDOWED |
WINED3DCAPS2_FULLSCREENGAMMA |
WINED3DCAPS2_DYNAMICTEXTURES ;
2007-10-03 13:19:15 +02:00
if ( GL_SUPPORT ( SGIS_GENERATE_MIPMAP ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > Caps2 | = WINED3DCAPS2_CANAUTOGENMIPMAP ;
}
2008-11-10 10:42:27 +01:00
pCaps - > Caps3 = WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD |
WINED3DCAPS3_COPY_TO_VIDMEM |
WINED3DCAPS3_COPY_TO_SYSTEMMEM ;
2008-03-18 19:26:00 +01:00
pCaps - > PresentationIntervals = WINED3DPRESENT_INTERVAL_IMMEDIATE |
WINED3DPRESENT_INTERVAL_ONE ;
pCaps - > CursorCaps = WINED3DCURSORCAPS_COLOR |
WINED3DCURSORCAPS_LOWRES ;
pCaps - > DevCaps = WINED3DDEVCAPS_FLOATTLVERTEX |
WINED3DDEVCAPS_EXECUTESYSTEMMEMORY |
WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY |
WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY |
WINED3DDEVCAPS_DRAWPRIMTLVERTEX |
WINED3DDEVCAPS_HWTRANSFORMANDLIGHT |
WINED3DDEVCAPS_EXECUTEVIDEOMEMORY |
WINED3DDEVCAPS_PUREDEVICE |
WINED3DDEVCAPS_HWRASTERIZATION |
WINED3DDEVCAPS_TEXTUREVIDEOMEMORY |
WINED3DDEVCAPS_TEXTURESYSTEMMEMORY |
WINED3DDEVCAPS_CANRENDERAFTERFLIP |
WINED3DDEVCAPS_DRAWPRIMITIVES2 |
WINED3DDEVCAPS_DRAWPRIMITIVES2EX |
WINED3DDEVCAPS_RTPATCHES ;
pCaps - > PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE |
WINED3DPMISCCAPS_CULLCCW |
WINED3DPMISCCAPS_CULLCW |
WINED3DPMISCCAPS_COLORWRITEENABLE |
WINED3DPMISCCAPS_CLIPTLVERTS |
WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
WINED3DPMISCCAPS_MASKZ |
2008-06-27 00:52:07 +02:00
WINED3DPMISCCAPS_BLENDOP |
WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING ;
2006-08-04 22:37:27 +02:00
/* TODO:
2007-02-14 23:31:05 +01:00
WINED3DPMISCCAPS_NULLREFERENCE
WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS
WINED3DPMISCCAPS_FOGANDSPECULARALPHA
WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
2006-08-04 22:37:27 +02:00
2008-02-16 16:42:11 +01:00
if ( GL_SUPPORT ( EXT_BLEND_EQUATION_SEPARATE ) & & GL_SUPPORT ( EXT_BLEND_FUNC_SEPARATE ) )
2008-03-18 19:26:00 +01:00
pCaps - > PrimitiveMiscCaps | = WINED3DPMISCCAPS_SEPARATEALPHABLEND ;
2008-02-16 16:42:11 +01:00
2008-03-18 19:26:00 +01:00
pCaps - > RasterCaps = WINED3DPRASTERCAPS_DITHER |
WINED3DPRASTERCAPS_PAT |
WINED3DPRASTERCAPS_WFOG |
WINED3DPRASTERCAPS_ZFOG |
WINED3DPRASTERCAPS_FOGVERTEX |
WINED3DPRASTERCAPS_FOGTABLE |
WINED3DPRASTERCAPS_STIPPLE |
WINED3DPRASTERCAPS_SUBPIXEL |
WINED3DPRASTERCAPS_ZTEST |
WINED3DPRASTERCAPS_SCISSORTEST |
WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
WINED3DPRASTERCAPS_DEPTHBIAS ;
2004-10-06 02:05:29 +02:00
if ( GL_SUPPORT ( EXT_TEXTURE_FILTER_ANISOTROPIC ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > RasterCaps | = WINED3DPRASTERCAPS_ANISOTROPY |
WINED3DPRASTERCAPS_ZBIAS |
WINED3DPRASTERCAPS_MIPMAPLODBIAS ;
2007-08-21 12:30:22 +02:00
}
if ( GL_SUPPORT ( NV_FOG_DISTANCE ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > RasterCaps | = WINED3DPRASTERCAPS_FOGRANGE ;
2004-10-06 02:05:29 +02:00
}
/* FIXME Add:
2009-01-09 10:23:43 +01:00
WINED3DPRASTERCAPS_COLORPERSPECTIVE
WINED3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
WINED3DPRASTERCAPS_ANTIALIASEDGES
WINED3DPRASTERCAPS_ZBUFFERLESSHSR
WINED3DPRASTERCAPS_WBUFFER */
2004-10-06 02:05:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
WINED3DPCMPCAPS_EQUAL |
WINED3DPCMPCAPS_GREATER |
WINED3DPCMPCAPS_GREATEREQUAL |
WINED3DPCMPCAPS_LESS |
WINED3DPCMPCAPS_LESSEQUAL |
WINED3DPCMPCAPS_NEVER |
WINED3DPCMPCAPS_NOTEQUAL ;
pCaps - > SrcBlendCaps = WINED3DPBLENDCAPS_BOTHINVSRCALPHA |
WINED3DPBLENDCAPS_BOTHSRCALPHA |
WINED3DPBLENDCAPS_DESTALPHA |
WINED3DPBLENDCAPS_DESTCOLOR |
WINED3DPBLENDCAPS_INVDESTALPHA |
WINED3DPBLENDCAPS_INVDESTCOLOR |
WINED3DPBLENDCAPS_INVSRCALPHA |
WINED3DPBLENDCAPS_INVSRCCOLOR |
WINED3DPBLENDCAPS_ONE |
WINED3DPBLENDCAPS_SRCALPHA |
WINED3DPBLENDCAPS_SRCALPHASAT |
WINED3DPBLENDCAPS_SRCCOLOR |
WINED3DPBLENDCAPS_ZERO ;
pCaps - > DestBlendCaps = WINED3DPBLENDCAPS_DESTALPHA |
WINED3DPBLENDCAPS_DESTCOLOR |
WINED3DPBLENDCAPS_INVDESTALPHA |
WINED3DPBLENDCAPS_INVDESTCOLOR |
WINED3DPBLENDCAPS_INVSRCALPHA |
WINED3DPBLENDCAPS_INVSRCCOLOR |
WINED3DPBLENDCAPS_ONE |
WINED3DPBLENDCAPS_SRCALPHA |
WINED3DPBLENDCAPS_SRCCOLOR |
WINED3DPBLENDCAPS_ZERO ;
2007-08-12 21:38:24 +02:00
/* NOTE: WINED3DPBLENDCAPS_SRCALPHASAT is not supported as dest blend factor,
* according to the glBlendFunc manpage
2007-08-12 21:44:30 +02:00
*
* WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA are
* legacy settings for srcblend only
2007-08-12 21:38:24 +02:00
*/
2006-08-04 19:14:16 +02:00
2008-01-13 00:32:24 +01:00
if ( GL_SUPPORT ( EXT_BLEND_COLOR ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > SrcBlendCaps | = WINED3DPBLENDCAPS_BLENDFACTOR ;
pCaps - > DestBlendCaps | = WINED3DPBLENDCAPS_BLENDFACTOR ;
}
pCaps - > AlphaCmpCaps = WINED3DPCMPCAPS_ALWAYS |
WINED3DPCMPCAPS_EQUAL |
WINED3DPCMPCAPS_GREATER |
WINED3DPCMPCAPS_GREATEREQUAL |
WINED3DPCMPCAPS_LESS |
WINED3DPCMPCAPS_LESSEQUAL |
WINED3DPCMPCAPS_NEVER |
WINED3DPCMPCAPS_NOTEQUAL ;
pCaps - > ShadeCaps = WINED3DPSHADECAPS_SPECULARGOURAUDRGB |
WINED3DPSHADECAPS_COLORGOURAUDRGB |
WINED3DPSHADECAPS_ALPHAFLATBLEND |
WINED3DPSHADECAPS_ALPHAGOURAUDBLEND |
WINED3DPSHADECAPS_COLORFLATRGB |
WINED3DPSHADECAPS_FOGFLAT |
WINED3DPSHADECAPS_FOGGOURAUD |
WINED3DPSHADECAPS_SPECULARFLATRGB ;
pCaps - > TextureCaps = WINED3DPTEXTURECAPS_ALPHA |
WINED3DPTEXTURECAPS_ALPHAPALETTE |
2008-08-20 20:51:41 +02:00
WINED3DPTEXTURECAPS_TRANSPARENCY |
2008-03-18 19:26:00 +01:00
WINED3DPTEXTURECAPS_BORDER |
WINED3DPTEXTURECAPS_MIPMAP |
WINED3DPTEXTURECAPS_PROJECTED |
WINED3DPTEXTURECAPS_PERSPECTIVE ;
2007-08-21 12:13:42 +02:00
if ( ! GL_SUPPORT ( ARB_TEXTURE_NON_POWER_OF_TWO ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > TextureCaps | = WINED3DPTEXTURECAPS_POW2 |
WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL ;
2007-08-21 12:13:42 +02:00
}
2004-10-06 02:05:29 +02:00
2006-08-05 00:11:17 +02:00
if ( GL_SUPPORT ( EXT_TEXTURE3D ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > TextureCaps | = WINED3DPTEXTURECAPS_VOLUMEMAP |
WINED3DPTEXTURECAPS_MIPVOLUMEMAP |
WINED3DPTEXTURECAPS_VOLUMEMAP_POW2 ;
2006-08-05 00:11:17 +02:00
}
2004-10-06 02:05:29 +02:00
if ( GL_SUPPORT ( ARB_TEXTURE_CUBE_MAP ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > TextureCaps | = WINED3DPTEXTURECAPS_CUBEMAP |
WINED3DPTEXTURECAPS_MIPCUBEMAP |
WINED3DPTEXTURECAPS_CUBEMAP_POW2 ;
2005-06-22 20:30:29 +02:00
2004-10-06 02:05:29 +02:00
}
2008-03-18 19:26:00 +01:00
pCaps - > TextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
WINED3DPTFILTERCAPS_MAGFPOINT |
WINED3DPTFILTERCAPS_MINFLINEAR |
WINED3DPTFILTERCAPS_MINFPOINT |
WINED3DPTFILTERCAPS_MIPFLINEAR |
WINED3DPTFILTERCAPS_MIPFPOINT |
WINED3DPTFILTERCAPS_LINEAR |
WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
WINED3DPTFILTERCAPS_MIPLINEAR |
WINED3DPTFILTERCAPS_MIPNEAREST |
WINED3DPTFILTERCAPS_NEAREST ;
2004-10-06 02:05:29 +02:00
2006-08-06 22:50:40 +02:00
if ( GL_SUPPORT ( EXT_TEXTURE_FILTER_ANISOTROPIC ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > TextureFilterCaps | = WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
WINED3DPTFILTERCAPS_MINFANISOTROPIC ;
2006-08-06 22:50:40 +02:00
}
if ( GL_SUPPORT ( ARB_TEXTURE_CUBE_MAP ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > CubeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
WINED3DPTFILTERCAPS_MAGFPOINT |
WINED3DPTFILTERCAPS_MINFLINEAR |
WINED3DPTFILTERCAPS_MINFPOINT |
WINED3DPTFILTERCAPS_MIPFLINEAR |
WINED3DPTFILTERCAPS_MIPFPOINT |
WINED3DPTFILTERCAPS_LINEAR |
WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
WINED3DPTFILTERCAPS_MIPLINEAR |
WINED3DPTFILTERCAPS_MIPNEAREST |
WINED3DPTFILTERCAPS_NEAREST ;
2006-08-06 22:50:40 +02:00
if ( GL_SUPPORT ( EXT_TEXTURE_FILTER_ANISOTROPIC ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > CubeTextureFilterCaps | = WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
2006-08-06 22:50:40 +02:00
WINED3DPTFILTERCAPS_MINFANISOTROPIC ;
}
} else
2008-03-18 19:26:00 +01:00
pCaps - > CubeTextureFilterCaps = 0 ;
2006-08-06 22:50:40 +02:00
if ( GL_SUPPORT ( EXT_TEXTURE3D ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > VolumeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
WINED3DPTFILTERCAPS_MAGFPOINT |
WINED3DPTFILTERCAPS_MINFLINEAR |
WINED3DPTFILTERCAPS_MINFPOINT |
WINED3DPTFILTERCAPS_MIPFLINEAR |
WINED3DPTFILTERCAPS_MIPFPOINT |
WINED3DPTFILTERCAPS_LINEAR |
WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
WINED3DPTFILTERCAPS_MIPLINEAR |
WINED3DPTFILTERCAPS_MIPNEAREST |
WINED3DPTFILTERCAPS_NEAREST ;
2006-08-06 22:50:40 +02:00
} else
2008-03-18 19:26:00 +01:00
pCaps - > VolumeTextureFilterCaps = 0 ;
2004-10-06 02:05:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > TextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
WINED3DPTADDRESSCAPS_CLAMP |
WINED3DPTADDRESSCAPS_WRAP ;
2004-10-06 02:05:29 +02:00
if ( GL_SUPPORT ( ARB_TEXTURE_BORDER_CLAMP ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > TextureAddressCaps | = WINED3DPTADDRESSCAPS_BORDER ;
2004-10-06 02:05:29 +02:00
}
if ( GL_SUPPORT ( ARB_TEXTURE_MIRRORED_REPEAT ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > TextureAddressCaps | = WINED3DPTADDRESSCAPS_MIRROR ;
2004-10-06 02:05:29 +02:00
}
if ( GL_SUPPORT ( ATI_TEXTURE_MIRROR_ONCE ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > TextureAddressCaps | = WINED3DPTADDRESSCAPS_MIRRORONCE ;
2004-10-06 02:05:29 +02:00
}
2006-08-08 17:50:33 +02:00
if ( GL_SUPPORT ( EXT_TEXTURE3D ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > VolumeTextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
WINED3DPTADDRESSCAPS_CLAMP |
WINED3DPTADDRESSCAPS_WRAP ;
2006-08-08 17:50:33 +02:00
if ( GL_SUPPORT ( ARB_TEXTURE_BORDER_CLAMP ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > VolumeTextureAddressCaps | = WINED3DPTADDRESSCAPS_BORDER ;
2006-08-08 17:50:33 +02:00
}
if ( GL_SUPPORT ( ARB_TEXTURE_MIRRORED_REPEAT ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > VolumeTextureAddressCaps | = WINED3DPTADDRESSCAPS_MIRROR ;
2006-08-08 17:50:33 +02:00
}
if ( GL_SUPPORT ( ATI_TEXTURE_MIRROR_ONCE ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > VolumeTextureAddressCaps | = WINED3DPTADDRESSCAPS_MIRRORONCE ;
2006-08-08 17:50:33 +02:00
}
} else
2008-03-18 19:26:00 +01:00
pCaps - > VolumeTextureAddressCaps = 0 ;
2004-10-06 02:05:29 +02:00
2008-08-19 16:34:54 +02:00
pCaps - > LineCaps = WINED3DLINECAPS_TEXTURE |
WINED3DLINECAPS_ZTEST |
WINED3DLINECAPS_BLEND |
WINED3DLINECAPS_ALPHACMP |
WINED3DLINECAPS_FOG ;
/* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
* idea how generating the smoothing alpha values works ; the result is different
*/
2004-10-06 02:05:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > MaxTextureWidth = GL_LIMITS ( texture_size ) ;
pCaps - > MaxTextureHeight = GL_LIMITS ( texture_size ) ;
2004-10-06 02:05:29 +02:00
2006-08-06 13:53:19 +02:00
if ( GL_SUPPORT ( EXT_TEXTURE3D ) )
2008-03-18 19:26:00 +01:00
pCaps - > MaxVolumeExtent = GL_LIMITS ( texture3d_size ) ;
2006-08-06 13:53:19 +02:00
else
2008-03-18 19:26:00 +01:00
pCaps - > MaxVolumeExtent = 0 ;
2004-10-06 02:05:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > MaxTextureRepeat = 32768 ;
pCaps - > MaxTextureAspectRatio = GL_LIMITS ( texture_size ) ;
pCaps - > MaxVertexW = 1.0 ;
2004-10-06 02:05:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > GuardBandLeft = 0 ;
pCaps - > GuardBandTop = 0 ;
pCaps - > GuardBandRight = 0 ;
pCaps - > GuardBandBottom = 0 ;
2004-10-06 02:05:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > ExtentsAdjust = 0 ;
2004-10-06 02:05:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > StencilCaps = WINED3DSTENCILCAPS_DECRSAT |
WINED3DSTENCILCAPS_INCRSAT |
WINED3DSTENCILCAPS_INVERT |
WINED3DSTENCILCAPS_KEEP |
WINED3DSTENCILCAPS_REPLACE |
WINED3DSTENCILCAPS_ZERO ;
2004-10-06 02:05:29 +02:00
if ( GL_SUPPORT ( EXT_STENCIL_WRAP ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > StencilCaps | = WINED3DSTENCILCAPS_DECR |
WINED3DSTENCILCAPS_INCR ;
2004-10-06 02:05:29 +02:00
}
2006-06-09 17:30:20 +02:00
if ( This - > dxVersion > 8 & &
( GL_SUPPORT ( EXT_STENCIL_TWO_SIDE ) | |
GL_SUPPORT ( ATI_SEPARATE_STENCIL ) ) ) {
2008-03-18 19:26:00 +01:00
pCaps - > StencilCaps | = WINED3DSTENCILCAPS_TWOSIDED ;
2006-06-09 17:30:20 +02:00
}
2004-10-06 02:05:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > FVFCaps = WINED3DFVFCAPS_PSIZE | 0x0008 ; /* 8 texture coords */
2005-06-22 20:30:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > MaxUserClipPlanes = GL_LIMITS ( clipplanes ) ;
pCaps - > MaxActiveLights = GL_LIMITS ( lights ) ;
2005-07-10 19:48:07 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > MaxVertexBlendMatrices = GL_LIMITS ( blends ) ;
pCaps - > MaxVertexBlendMatrixIndex = 0 ;
2004-10-06 02:05:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > MaxAnisotropy = GL_LIMITS ( anisotropy ) ;
pCaps - > MaxPointSize = GL_LIMITS ( pointsize ) ;
2004-10-06 02:05:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > VertexProcessingCaps = WINED3DVTXPCAPS_DIRECTIONALLIGHTS |
WINED3DVTXPCAPS_MATERIALSOURCE7 |
WINED3DVTXPCAPS_POSITIONALLIGHTS |
WINED3DVTXPCAPS_LOCALVIEWER |
WINED3DVTXPCAPS_VERTEXFOG |
WINED3DVTXPCAPS_TEXGEN ;
2004-10-06 02:05:29 +02:00
/* FIXME: Add
2006-08-08 17:46:03 +02:00
D3DVTXPCAPS_TWEENING , D3DVTXPCAPS_TEXGEN_SPHEREMAP */
2004-10-06 02:05:29 +02:00
2008-03-18 19:26:00 +01:00
pCaps - > MaxPrimitiveCount = 0xFFFFF ; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
pCaps - > MaxVertexIndex = 0xFFFFF ;
pCaps - > MaxStreams = MAX_STREAMS ;
pCaps - > MaxStreamStride = 1024 ;
2004-10-06 02:05:29 +02:00
2008-03-18 19:26:00 +01:00
/* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
2008-07-12 18:22:18 +02:00
pCaps - > DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET |
WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET ;
2008-03-18 19:26:00 +01:00
pCaps - > MaxNpatchTessellationLevel = 0 ;
pCaps - > MasterAdapterOrdinal = 0 ;
pCaps - > AdapterOrdinalInGroup = 0 ;
pCaps - > NumberOfAdaptersInGroup = 1 ;
2008-03-18 19:39:26 +01:00
pCaps - > NumSimultaneousRTs = GL_LIMITS ( buffers ) ;
pCaps - > StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT |
WINED3DPTFILTERCAPS_MAGFPOINT |
WINED3DPTFILTERCAPS_MINFLINEAR |
WINED3DPTFILTERCAPS_MAGFLINEAR ;
pCaps - > VertexTextureFilterCaps = 0 ;
memset ( & shader_caps , 0 , sizeof ( shader_caps ) ) ;
2009-03-11 10:15:09 +01:00
shader_backend = select_shader_backend ( adapter , DeviceType ) ;
shader_backend - > shader_get_caps ( DeviceType , & adapter - > gl_info , & shader_caps ) ;
2008-03-18 19:39:26 +01:00
2008-07-03 21:36:18 +02:00
memset ( & fragment_caps , 0 , sizeof ( fragment_caps ) ) ;
2009-03-11 10:15:09 +01:00
frag_pipeline = select_fragment_implementation ( adapter , DeviceType ) ;
frag_pipeline - > get_caps ( DeviceType , & adapter - > gl_info , & fragment_caps ) ;
2008-07-03 21:36:18 +02:00
2008-03-29 23:55:09 +01:00
/* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
2008-07-03 21:36:18 +02:00
pCaps - > PrimitiveMiscCaps | = fragment_caps . PrimitiveMiscCaps ;
2008-03-29 23:55:09 +01:00
2008-03-22 14:27:53 +01:00
/* This takes care for disabling vertex shader or pixel shader caps while leaving the other one enabled.
* Ignore shader model capabilities if disabled in config
*/
if ( vs_selected_mode = = SHADER_NONE ) {
TRACE_ ( d3d_caps ) ( " Vertex shader disabled in config, reporting version 0.0 \n " ) ;
pCaps - > VertexShaderVersion = WINED3DVS_VERSION ( 0 , 0 ) ;
pCaps - > MaxVertexShaderConst = 0 ;
} else {
pCaps - > VertexShaderVersion = shader_caps . VertexShaderVersion ;
pCaps - > MaxVertexShaderConst = shader_caps . MaxVertexShaderConst ;
}
if ( ps_selected_mode = = SHADER_NONE ) {
TRACE_ ( d3d_caps ) ( " Pixel shader disabled in config, reporting version 0.0 \n " ) ;
pCaps - > PixelShaderVersion = WINED3DPS_VERSION ( 0 , 0 ) ;
pCaps - > PixelShader1xMaxValue = 0.0 ;
} else {
pCaps - > PixelShaderVersion = shader_caps . PixelShaderVersion ;
pCaps - > PixelShader1xMaxValue = shader_caps . PixelShader1xMaxValue ;
}
2008-07-03 21:36:18 +02:00
pCaps - > TextureOpCaps = fragment_caps . TextureOpCaps ;
pCaps - > MaxTextureBlendStages = fragment_caps . MaxTextureBlendStages ;
pCaps - > MaxSimultaneousTextures = fragment_caps . MaxSimultaneousTextures ;
2008-03-18 19:39:26 +01:00
pCaps - > VS20Caps = shader_caps . VS20Caps ;
pCaps - > MaxVShaderInstructionsExecuted = shader_caps . MaxVShaderInstructionsExecuted ;
pCaps - > MaxVertexShader30InstructionSlots = shader_caps . MaxVertexShader30InstructionSlots ;
pCaps - > PS20Caps = shader_caps . PS20Caps ;
pCaps - > MaxPShaderInstructionsExecuted = shader_caps . MaxPShaderInstructionsExecuted ;
pCaps - > MaxPixelShader30InstructionSlots = shader_caps . MaxPixelShader30InstructionSlots ;
2008-03-22 14:27:53 +01:00
/* The following caps are shader specific, but they are things we cannot detect, or which
* are the same among all shader models . So to avoid code duplication set the shader version
* specific , but otherwise constant caps here
*/
if ( pCaps - > VertexShaderVersion = = WINED3DVS_VERSION ( 3 , 0 ) ) {
/* Where possible set the caps based on OpenGL extensions and if they aren't set (in case of software rendering)
use the VS 3.0 from MSDN or else if there ' s OpenGL spec use a hardcoded value minimum VS3 .0 value . */
pCaps - > VS20Caps . Caps = WINED3DVS20CAPS_PREDICATION ;
pCaps - > VS20Caps . DynamicFlowControlDepth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH ; /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
2009-03-11 10:15:09 +01:00
pCaps - > VS20Caps . NumTemps = max ( 32 , adapter - > gl_info . vs_arb_max_temps ) ;
2008-03-22 14:27:53 +01:00
pCaps - > VS20Caps . StaticFlowControlDepth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH ; /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
pCaps - > MaxVShaderInstructionsExecuted = 65535 ; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
2009-03-11 10:15:09 +01:00
pCaps - > MaxVertexShader30InstructionSlots = max ( 512 , adapter - > gl_info . vs_arb_max_instructions ) ;
2008-03-22 14:27:53 +01:00
} else if ( pCaps - > VertexShaderVersion = = WINED3DVS_VERSION ( 2 , 0 ) ) {
pCaps - > VS20Caps . Caps = 0 ;
pCaps - > VS20Caps . DynamicFlowControlDepth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH ;
2009-03-11 10:15:09 +01:00
pCaps - > VS20Caps . NumTemps = max ( 12 , adapter - > gl_info . vs_arb_max_temps ) ;
2008-03-22 14:27:53 +01:00
pCaps - > VS20Caps . StaticFlowControlDepth = 1 ;
pCaps - > MaxVShaderInstructionsExecuted = 65535 ;
pCaps - > MaxVertexShader30InstructionSlots = 0 ;
} else { /* VS 1.x */
pCaps - > VS20Caps . Caps = 0 ;
pCaps - > VS20Caps . DynamicFlowControlDepth = 0 ;
pCaps - > VS20Caps . NumTemps = 0 ;
pCaps - > VS20Caps . StaticFlowControlDepth = 0 ;
pCaps - > MaxVShaderInstructionsExecuted = 0 ;
pCaps - > MaxVertexShader30InstructionSlots = 0 ;
}
if ( pCaps - > PixelShaderVersion = = WINED3DPS_VERSION ( 3 , 0 ) ) {
/* Where possible set the caps based on OpenGL extensions and if they aren't set (in case of software rendering)
use the PS 3.0 from MSDN or else if there ' s OpenGL spec use a hardcoded value minimum PS 3.0 value . */
/* 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 */
pCaps - > PS20Caps . Caps = WINED3DPS20CAPS_ARBITRARYSWIZZLE |
WINED3DPS20CAPS_GRADIENTINSTRUCTIONS |
WINED3DPS20CAPS_PREDICATION |
WINED3DPS20CAPS_NODEPENDENTREADLIMIT |
WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT ;
pCaps - > PS20Caps . DynamicFlowControlDepth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH ; /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
2009-03-11 10:15:09 +01:00
pCaps - > PS20Caps . NumTemps = max ( 32 , adapter - > gl_info . ps_arb_max_temps ) ;
2008-03-22 14:27:53 +01:00
pCaps - > PS20Caps . StaticFlowControlDepth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH ; /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
pCaps - > PS20Caps . NumInstructionSlots = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS ; /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
pCaps - > MaxPShaderInstructionsExecuted = 65535 ;
2009-03-11 10:15:09 +01:00
pCaps - > MaxPixelShader30InstructionSlots = max ( WINED3DMIN30SHADERINSTRUCTIONS , adapter - > gl_info . ps_arb_max_instructions ) ;
2008-03-22 14:27:53 +01:00
} else if ( pCaps - > PixelShaderVersion = = WINED3DPS_VERSION ( 2 , 0 ) ) {
/* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
pCaps - > PS20Caps . Caps = 0 ;
pCaps - > PS20Caps . DynamicFlowControlDepth = 0 ; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
2009-03-11 10:15:09 +01:00
pCaps - > PS20Caps . NumTemps = max ( 12 , adapter - > gl_info . ps_arb_max_temps ) ;
2008-03-22 14:27:53 +01:00
pCaps - > PS20Caps . StaticFlowControlDepth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH ; /* Minimum: 1 */
pCaps - > PS20Caps . NumInstructionSlots = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS ; /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
pCaps - > MaxPShaderInstructionsExecuted = 512 ; /* Minimum value, a GeforceFX uses 1024 */
pCaps - > MaxPixelShader30InstructionSlots = 0 ;
} else { /* PS 1.x */
pCaps - > PS20Caps . Caps = 0 ;
pCaps - > PS20Caps . DynamicFlowControlDepth = 0 ;
pCaps - > PS20Caps . NumTemps = 0 ;
pCaps - > PS20Caps . StaticFlowControlDepth = 0 ;
pCaps - > PS20Caps . NumInstructionSlots = 0 ;
pCaps - > MaxPShaderInstructionsExecuted = 0 ;
pCaps - > MaxPixelShader30InstructionSlots = 0 ;
}
2008-03-18 19:26:00 +01:00
if ( pCaps - > VertexShaderVersion > = WINED3DVS_VERSION ( 2 , 0 ) ) {
/* OpenGL supports all the formats below, perhaps not always
* without conversion , but it supports them .
* Further GLSL doesn ' t seem to have an official unsigned type so
* don ' t advertise it yet as I ' m not sure how we handle it .
* We might need to add some clamping in the shader engine to
* support it .
* TODO : WINED3DDTCAPS_USHORT2N , WINED3DDTCAPS_USHORT4N , WINED3DDTCAPS_UDEC3 , WINED3DDTCAPS_DEC3N */
pCaps - > DeclTypes = WINED3DDTCAPS_UBYTE4 |
2008-03-18 19:39:26 +01:00
WINED3DDTCAPS_UBYTE4N |
WINED3DDTCAPS_SHORT2N |
WINED3DDTCAPS_SHORT4N ;
2008-03-18 19:26:00 +01:00
if ( GL_SUPPORT ( NV_HALF_FLOAT ) ) {
2008-03-18 19:39:26 +01:00
pCaps - > DeclTypes | = WINED3DDTCAPS_FLOAT16_2 |
WINED3DDTCAPS_FLOAT16_4 ;
2006-08-08 10:57:15 +02:00
}
2008-03-18 19:26:00 +01:00
} else
pCaps - > DeclTypes = 0 ;
2008-07-29 18:03:59 +02:00
/* Set DirectDraw helper Caps */
ckey_caps = WINEDDCKEYCAPS_DESTBLT |
WINEDDCKEYCAPS_SRCBLT ;
fx_caps = WINEDDFXCAPS_BLTALPHA |
WINEDDFXCAPS_BLTMIRRORLEFTRIGHT |
WINEDDFXCAPS_BLTMIRRORUPDOWN |
WINEDDFXCAPS_BLTROTATION90 |
WINEDDFXCAPS_BLTSHRINKX |
WINEDDFXCAPS_BLTSHRINKXN |
WINEDDFXCAPS_BLTSHRINKY |
WINEDDFXCAPS_BLTSHRINKXN |
WINEDDFXCAPS_BLTSTRETCHX |
WINEDDFXCAPS_BLTSTRETCHXN |
WINEDDFXCAPS_BLTSTRETCHY |
WINEDDFXCAPS_BLTSTRETCHYN ;
blit_caps = WINEDDCAPS_BLT |
WINEDDCAPS_BLTCOLORFILL |
WINEDDCAPS_BLTDEPTHFILL |
WINEDDCAPS_BLTSTRETCH |
WINEDDCAPS_CANBLTSYSMEM |
WINEDDCAPS_CANCLIP |
WINEDDCAPS_CANCLIPSTRETCHED |
WINEDDCAPS_COLORKEY |
WINEDDCAPS_COLORKEYHWASSIST |
WINEDDCAPS_ALIGNBOUNDARYSRC ;
/* Fill the ddraw caps structure */
pCaps - > DirectDrawCaps . Caps = WINEDDCAPS_GDI |
WINEDDCAPS_PALETTE |
2008-07-23 22:38:52 +02:00
blit_caps ;
2008-07-29 18:03:59 +02:00
pCaps - > DirectDrawCaps . Caps2 = WINEDDCAPS2_CERTIFIED |
WINEDDCAPS2_NOPAGELOCKREQUIRED |
WINEDDCAPS2_PRIMARYGAMMA |
WINEDDCAPS2_WIDESURFACES |
WINEDDCAPS2_CANRENDERWINDOWED ;
pCaps - > DirectDrawCaps . SVBCaps = blit_caps ;
pCaps - > DirectDrawCaps . SVBCKeyCaps = ckey_caps ;
pCaps - > DirectDrawCaps . SVBFXCaps = fx_caps ;
pCaps - > DirectDrawCaps . VSBCaps = blit_caps ;
pCaps - > DirectDrawCaps . VSBCKeyCaps = ckey_caps ;
pCaps - > DirectDrawCaps . VSBFXCaps = fx_caps ;
pCaps - > DirectDrawCaps . SSBCaps = blit_caps ;
pCaps - > DirectDrawCaps . SSBCKeyCaps = ckey_caps ;
pCaps - > DirectDrawCaps . SSBFXCaps = fx_caps ;
pCaps - > DirectDrawCaps . ddsCaps = WINEDDSCAPS_ALPHA |
WINEDDSCAPS_BACKBUFFER |
WINEDDSCAPS_FLIP |
WINEDDSCAPS_FRONTBUFFER |
WINEDDSCAPS_OFFSCREENPLAIN |
WINEDDSCAPS_PALETTE |
WINEDDSCAPS_PRIMARYSURFACE |
WINEDDSCAPS_SYSTEMMEMORY |
WINEDDSCAPS_VIDEOMEMORY |
2008-07-23 22:38:52 +02:00
WINEDDSCAPS_VISIBLE ;
2008-08-03 01:06:01 +02:00
pCaps - > DirectDrawCaps . StrideAlign = DDRAW_PITCH_ALIGNMENT ;
2008-07-23 22:38:52 +02:00
/* Set D3D caps if OpenGL is available. */
2009-03-11 10:15:09 +01:00
if ( adapter - > opengl )
{
2008-07-23 22:38:52 +02:00
pCaps - > DirectDrawCaps . ddsCaps | = WINEDDSCAPS_3DDEVICE |
WINEDDSCAPS_MIPMAP |
WINEDDSCAPS_TEXTURE |
WINEDDSCAPS_ZBUFFER ;
pCaps - > DirectDrawCaps . Caps | = WINEDDCAPS_3D ;
}
2006-04-07 12:51:12 +02:00
return WINED3D_OK ;
2004-10-06 02:05:29 +02:00
}
2004-10-07 06:22:21 +02:00
/* Note due to structure differences between dx8 and dx9 D3DPRESENT_PARAMETERS,
and fields being inserted in the middle , a new structure is used in place */
2009-01-16 10:14:24 +01:00
static HRESULT WINAPI IWineD3DImpl_CreateDevice ( IWineD3D * iface , UINT Adapter ,
WINED3DDEVTYPE DeviceType , HWND hFocusWindow , DWORD BehaviourFlags , IUnknown * parent ,
IWineD3DDeviceParent * device_parent , IWineD3DDevice * * ppReturnedDeviceInterface )
{
2004-10-08 22:52:33 +02:00
IWineD3DDeviceImpl * object = NULL ;
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
2009-03-11 10:15:09 +01:00
struct WineD3DAdapter * adapter = & This - > adapters [ Adapter ] ;
2007-12-06 23:43:25 +01:00
WINED3DDISPLAYMODE mode ;
2008-07-04 22:09:49 +02:00
const struct fragment_pipeline * frag_pipeline = NULL ;
2007-07-04 17:57:45 +02:00
int i ;
2008-08-17 23:46:47 +02:00
struct fragment_caps ffp_caps ;
2009-01-07 02:20:08 +01:00
HRESULT hr ;
2004-10-08 22:52:33 +02:00
2007-07-16 20:53:44 +02:00
/* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
* number and create a device without a 3 D adapter for 2 D only operation .
*/
if ( IWineD3D_GetAdapterCount ( iface ) & & Adapter > = IWineD3D_GetAdapterCount ( iface ) ) {
2006-04-07 12:51:12 +02:00
return WINED3DERR_INVALIDCALL ;
2004-10-08 22:52:33 +02:00
}
2004-10-07 06:22:21 +02:00
/* Create a WineD3DDevice object */
2004-10-08 22:52:33 +02:00
object = HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , sizeof ( IWineD3DDeviceImpl ) ) ;
* ppReturnedDeviceInterface = ( IWineD3DDevice * ) object ;
2005-11-10 13:14:56 +01:00
TRACE ( " Created WineD3DDevice object @ %p \n " , object ) ;
2004-10-08 22:52:33 +02:00
if ( NULL = = object ) {
2006-04-07 12:51:12 +02:00
return WINED3DERR_OUTOFVIDEOMEMORY ;
2004-10-08 22:52:33 +02:00
}
/* Set up initial COM information */
2004-10-07 06:22:21 +02:00
object - > lpVtbl = & IWineD3DDevice_Vtbl ;
object - > ref = 1 ;
2004-11-28 16:04:41 +01:00
object - > wineD3D = iface ;
2009-03-11 10:15:09 +01:00
object - > adapter = This - > adapter_count ? adapter : NULL ;
2004-11-28 16:04:41 +01:00
IWineD3D_AddRef ( object - > wineD3D ) ;
2004-11-23 14:52:46 +01:00
object - > parent = parent ;
2009-01-16 10:14:24 +01:00
object - > device_parent = device_parent ;
2007-11-16 20:28:45 +01:00
list_init ( & object - > resources ) ;
2008-01-08 20:45:59 +01:00
list_init ( & object - > shaders ) ;
2005-07-13 16:15:54 +02:00
2007-06-08 22:28:04 +02:00
if ( This - > dxVersion = = 7 ) {
2008-08-03 01:06:01 +02:00
object - > surface_alignment = DDRAW_PITCH_ALIGNMENT ;
2007-06-08 22:28:04 +02:00
} else {
2008-08-03 01:06:01 +02:00
object - > surface_alignment = D3D8_PITCH_ALIGNMENT ;
2007-06-08 22:28:04 +02:00
}
2007-11-02 01:11:15 +01:00
object - > posFixup [ 0 ] = 1.0 ; /* This is needed to get the x coord unmodified through a MAD */
2007-06-08 22:28:04 +02:00
2005-09-21 12:55:03 +02:00
/* Set the state up as invalid until the device is fully created */
2006-04-07 12:51:12 +02:00
object - > state = WINED3DERR_DRIVERINTERNALERROR ;
2005-09-21 12:55:03 +02:00
2006-10-01 05:20:10 +02:00
TRACE ( " (%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %x, RetDevInt: %p) \n " , This , Adapter , DeviceType ,
2006-04-18 22:38:30 +02:00
hFocusWindow , BehaviourFlags , ppReturnedDeviceInterface ) ;
2004-10-08 22:52:33 +02:00
/* Save the creation parameters */
object - > createParms . AdapterOrdinal = Adapter ;
object - > createParms . DeviceType = DeviceType ;
object - > createParms . hFocusWindow = hFocusWindow ;
object - > createParms . BehaviorFlags = BehaviourFlags ;
/* Initialize other useful values */
object - > adapterNo = Adapter ;
object - > devType = DeviceType ;
2009-03-11 10:15:09 +01:00
select_shader_mode ( & adapter - > gl_info , DeviceType ,
& object - > ps_selected_mode , & object - > vs_selected_mode ) ;
object - > shader_backend = select_shader_backend ( adapter , DeviceType ) ;
2006-10-08 05:25:01 +02:00
2008-08-17 23:46:47 +02:00
memset ( & ffp_caps , 0 , sizeof ( ffp_caps ) ) ;
2009-03-11 10:15:09 +01:00
frag_pipeline = select_fragment_implementation ( adapter , DeviceType ) ;
2008-07-04 22:09:49 +02:00
object - > frag_pipe = frag_pipeline ;
2009-03-11 10:15:09 +01:00
frag_pipeline - > get_caps ( DeviceType , & adapter - > gl_info , & ffp_caps ) ;
2008-08-17 23:46:47 +02:00
object - > max_ffp_textures = ffp_caps . MaxSimultaneousTextures ;
2008-08-21 20:23:38 +02:00
object - > max_ffp_texture_stages = ffp_caps . MaxTextureBlendStages ;
2009-03-11 10:15:09 +01:00
hr = compile_state_table ( object - > StateTable , object - > multistate_funcs , & adapter - > gl_info ,
2008-07-02 21:56:38 +02:00
ffp_vertexstate_template , frag_pipeline , misc_state_template ) ;
2008-08-17 23:46:47 +02:00
2009-01-07 02:20:08 +01:00
if ( FAILED ( hr ) ) {
IWineD3D_Release ( object - > wineD3D ) ;
HeapFree ( GetProcessHeap ( ) , 0 , object ) ;
return hr ;
}
2009-03-11 10:15:09 +01:00
object - > blitter = select_blit_implementation ( adapter , DeviceType ) ;
2008-07-02 01:23:44 +02:00
2005-09-21 12:55:03 +02:00
/* set the state of the device to valid */
2006-04-07 12:51:12 +02:00
object - > state = WINED3D_OK ;
2005-09-21 12:55:03 +02:00
2006-05-18 22:42:22 +02:00
/* Get the initial screen setup for ddraw */
2007-12-06 23:43:25 +01:00
IWineD3DImpl_GetAdapterDisplayMode ( iface , Adapter , & mode ) ;
object - > ddraw_width = mode . Width ;
object - > ddraw_height = mode . Height ;
object - > ddraw_format = mode . Format ;
2006-05-18 22:42:22 +02:00
2007-07-04 17:57:45 +02:00
for ( i = 0 ; i < PATCHMAP_SIZE ; i + + ) {
list_init ( & object - > patches [ i ] ) ;
}
2009-02-23 09:16:01 +01:00
IWineD3DDeviceParent_WineD3DDeviceCreated ( device_parent , * ppReturnedDeviceInterface ) ;
2006-04-07 12:51:12 +02:00
return WINED3D_OK ;
2004-10-07 06:22:21 +02:00
}
2006-06-10 13:15:32 +02:00
static HRESULT WINAPI IWineD3DImpl_GetParent ( IWineD3D * iface , IUnknown * * pParent ) {
2004-11-23 14:52:46 +01:00
IWineD3DImpl * This = ( IWineD3DImpl * ) iface ;
IUnknown_AddRef ( This - > parent ) ;
* pParent = This - > parent ;
2006-04-07 12:51:12 +02:00
return WINED3D_OK ;
2004-11-23 14:52:46 +01:00
}
2006-12-05 00:28:58 +01:00
ULONG WINAPI D3DCB_DefaultDestroySurface ( IWineD3DSurface * pSurface ) {
IUnknown * surfaceParent ;
TRACE ( " (%p) call back \n " , pSurface ) ;
/* Now, release the parent, which will take care of cleaning up the surface for us */
IWineD3DSurface_GetParent ( pSurface , & surfaceParent ) ;
IUnknown_Release ( surfaceParent ) ;
return IUnknown_Release ( surfaceParent ) ;
}
2006-12-05 00:29:21 +01:00
ULONG WINAPI D3DCB_DefaultDestroyVolume ( IWineD3DVolume * pVolume ) {
IUnknown * volumeParent ;
TRACE ( " (%p) call back \n " , pVolume ) ;
/* Now, release the parent, which will take care of cleaning up the volume for us */
IWineD3DVolume_GetParent ( pVolume , & volumeParent ) ;
IUnknown_Release ( volumeParent ) ;
return IUnknown_Release ( volumeParent ) ;
}
2008-11-28 15:30:11 +01:00
static BOOL implementation_is_apple ( const WineD3D_GL_Info * gl_info )
{
2007-11-08 22:08:08 +01:00
/* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
* the opengl 1.2 + core , while other extensions are advertised , but software emulated . So try to
* detect the Apple OpenGL implementation to apply some extension fixups afterwards .
*
* Detecting this isn ' t really easy . The vendor string doesn ' t mention Apple . Compile - time checks
* aren ' t sufficient either because a Linux binary may display on a macos X server via remote X11 .
* So try to detect the GL implementation by looking at certain Apple extensions . Some extensions
* like client storage might be supported on other implementations too , but GL_APPLE_flush_render
2007-12-07 01:03:54 +01:00
* is specific to the Mac OS X window management , and GL_APPLE_ycbcr_422 is QuickTime specific . So
* the chance that other implementations support them is rather small since Win32 QuickTime uses
2007-11-08 22:08:08 +01:00
* DirectDraw , not OpenGL .
*/
if ( gl_info - > supported [ APPLE_FENCE ] & &
gl_info - > supported [ APPLE_CLIENT_STORAGE ] & &
gl_info - > supported [ APPLE_FLUSH_RENDER ] & &
gl_info - > supported [ APPLE_YCBCR_422 ] ) {
TRACE_ ( d3d_caps ) ( " GL_APPLE_fence, GL_APPLE_client_storage, GL_APPLE_flush_render and GL_ycbcr_422 are supported \n " ) ;
TRACE_ ( d3d_caps ) ( " Activating MacOS fixups \n " ) ;
return TRUE ;
} else {
TRACE_ ( d3d_caps ) ( " Apple extensions are not supported \n " ) ;
TRACE_ ( d3d_caps ) ( " Not activating MacOS fixups \n " ) ;
return FALSE ;
}
}
2008-02-11 01:55:11 +01:00
static void test_pbo_functionality ( WineD3D_GL_Info * gl_info ) {
/* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
* but glTexSubImage from a PBO fails miserably , with the first line repeated over
* all the texture . This function detects this bug by its symptom and disables PBOs
* if the test fails .
*
2008-04-22 08:18:14 +02:00
* The test uploads a 4 x4 texture via the PBO in the " native " format GL_BGRA ,
2008-02-11 01:55:11 +01:00
* GL_UNSIGNED_INT_8_8_8_8_REV . This format triggers the bug , and it is what we use
* for D3DFMT_A8R8G8B8 . Then the texture is read back without any PBO and the data
* read back is compared to the original . If they are equal PBOs are assumed to work ,
* otherwise the PBO extension is disabled .
*/
GLuint texture , pbo ;
static const unsigned int pattern [ ] = {
0x00000000 , 0x000000ff , 0x0000ff00 , 0x40ff0000 ,
0x80ffffff , 0x40ffff00 , 0x00ff00ff , 0x0000ffff ,
0x00ffff00 , 0x00ff00ff , 0x0000ffff , 0x000000ff ,
0x80ff00ff , 0x0000ffff , 0x00ff00ff , 0x40ff00ff
} ;
unsigned int check [ sizeof ( pattern ) / sizeof ( pattern [ 0 ] ) ] ;
if ( ! gl_info - > supported [ ARB_PIXEL_BUFFER_OBJECT ] ) {
/* No PBO -> No point in testing them */
return ;
}
while ( glGetError ( ) ) ;
glGenTextures ( 1 , & texture ) ;
glBindTexture ( GL_TEXTURE_2D , texture ) ;
2008-08-23 23:14:10 +02:00
glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA8 , 4 , 4 , 0 , GL_BGRA , GL_UNSIGNED_INT_8_8_8_8_REV , 0 ) ;
2008-02-11 01:55:11 +01:00
checkGLcall ( " Specifying the PBO test texture \n " ) ;
GL_EXTCALL ( glGenBuffersARB ( 1 , & pbo ) ) ;
GL_EXTCALL ( glBindBufferARB ( GL_PIXEL_UNPACK_BUFFER_ARB , pbo ) ) ;
GL_EXTCALL ( glBufferDataARB ( GL_PIXEL_UNPACK_BUFFER_ARB , sizeof ( pattern ) , pattern , GL_STREAM_DRAW_ARB ) ) ;
checkGLcall ( " Specifying the PBO test pbo \n " ) ;
glTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , 4 , 4 , GL_BGRA , GL_UNSIGNED_INT_8_8_8_8_REV , NULL ) ;
checkGLcall ( " Loading the PBO test texture \n " ) ;
GL_EXTCALL ( glBindBufferARB ( GL_PIXEL_UNPACK_BUFFER_ARB , 0 ) ) ;
glFinish ( ) ; /* just to be sure */
memset ( check , 0 , sizeof ( check ) ) ;
glGetTexImage ( GL_TEXTURE_2D , 0 , GL_BGRA , GL_UNSIGNED_INT_8_8_8_8_REV , check ) ;
checkGLcall ( " Reading back the PBO test texture \n " ) ;
glDeleteTextures ( 1 , & texture ) ;
GL_EXTCALL ( glDeleteBuffersARB ( 1 , & pbo ) ) ;
checkGLcall ( " PBO test cleanup \n " ) ;
if ( memcmp ( check , pattern , sizeof ( check ) ) ! = 0 ) {
WARN_ ( d3d_caps ) ( " PBO test failed, read back data doesn't match original \n " ) ;
WARN_ ( d3d_caps ) ( " Disabling PBOs. This may result in slower performance \n " ) ;
gl_info - > supported [ ARB_PIXEL_BUFFER_OBJECT ] = FALSE ;
} else {
2008-03-01 21:10:38 +01:00
TRACE_ ( d3d_caps ) ( " PBO test successful \n " ) ;
2008-02-11 01:55:11 +01:00
}
}
2008-02-06 16:09:29 +01:00
/* Certain applications(Steam) complain if we report an outdated driver version. In general,
* reporting a driver version is moot because we are not the Windows driver , and we have different
* bugs , features , etc .
*
* If a card is not found in this table , the gl driver version is reported
*/
struct driver_version_information {
WORD vendor ; /* reported PCI card vendor ID */
WORD card ; /* reported PCI card device ID */
WORD hipart_hi , hipart_lo ; /* driver hiword to report */
WORD lopart_hi , lopart_lo ; /* driver loword to report */
} ;
static const struct driver_version_information driver_version_table [ ] = {
2008-06-21 22:19:04 +02:00
/* Nvidia drivers. Geforce6 and newer cards are supported by the current driver (177.x)*/
2008-07-10 00:25:28 +02:00
/* GeforceFX support is up to 173.x, Geforce2MX/3/4 up to 96.x, TNT/Geforce1/2 up to 71.x */
2008-06-15 19:17:56 +02:00
/* Note that version numbers >100 lets say 123.45 use >= x.y.11.2345 and not x.y.10.12345 */
2008-06-21 22:19:04 +02:00
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCEFX_5200 , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCEFX_5600 , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCEFX_5800 , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_6200 , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_6600GT , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_6800 , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_7400 , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_7300 , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_7600 , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_7800GT , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_8300GS , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_8600GT , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_8600MGT , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_8800GTS , 7 , 15 , 11 , 7341 } ,
2008-06-15 19:17:56 +02:00
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_9600GT , 7 , 15 , 11 , 7341 } ,
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_9800GT , 7 , 15 , 11 , 7341 } ,
2008-11-22 00:54:46 +01:00
{ VENDOR_NVIDIA , CARD_NVIDIA_GEFORCE_GTX280 , 7 , 15 , 11 , 7341 } ,
2008-02-06 16:09:29 +01:00
2008-02-06 16:10:48 +01:00
/* ATI cards. The driver versions are somewhat similar, but not quite the same. Let's hardcode */
{ VENDOR_ATI , CARD_ATI_RADEON_9500 , 6 , 14 , 10 , 6764 } ,
{ VENDOR_ATI , CARD_ATI_RADEON_X700 , 6 , 14 , 10 , 6764 } ,
{ VENDOR_ATI , CARD_ATI_RADEON_X1600 , 6 , 14 , 10 , 6764 } ,
{ VENDOR_ATI , CARD_ATI_RADEON_HD2300 , 6 , 14 , 10 , 6764 } ,
{ VENDOR_ATI , CARD_ATI_RADEON_HD2600 , 6 , 14 , 10 , 6764 } ,
{ VENDOR_ATI , CARD_ATI_RADEON_HD2900 , 6 , 14 , 10 , 6764 } ,
/* TODO: Add information about legacy nvidia and ATI hardware, Intel and other cards */
2008-02-06 16:09:29 +01:00
} ;
2007-11-08 22:10:17 +01:00
static void fixup_extensions ( WineD3D_GL_Info * gl_info ) {
2008-02-06 16:09:29 +01:00
unsigned int i ;
BOOL apple = implementation_is_apple ( gl_info ) ;
if ( apple ) {
2007-12-07 01:03:54 +01:00
/* MacOS advertises more GLSL vertex shader uniforms than supported by the hardware, and if more are
2007-11-08 22:10:17 +01:00
* used it falls back to software . While the compiler can detect if the shader uses all declared
* uniforms , the optimization fails if the shader uses relative addressing . So any GLSL shader
* using relative addressing falls back to software .
*
* ARB vp gives the correct amount of uniforms , so use it instead of GLSL
*/
if ( gl_info - > vs_glsl_constantsF < = gl_info - > vs_arb_constantsF ) {
FIXME ( " GLSL doesn't advertise more vertex shader uniforms than ARB. Driver fixup outdated? \n " ) ;
} else {
TRACE ( " Driver claims %u GLSL vs uniforms, replacing with %u ARB vp uniforms \n " ,
gl_info - > vs_glsl_constantsF , gl_info - > vs_arb_constantsF ) ;
gl_info - > vs_glsl_constantsF = gl_info - > vs_arb_constantsF ;
}
2007-11-06 12:39:57 +01:00
2007-12-06 22:10:11 +01:00
/* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
* with fixed function fragment processing . Ideally this flag should be detected with a test shader
2008-01-09 20:37:05 +01:00
* and OpenGL feedback mode , but some GL implementations ( MacOS ATI at least , probably all MacOS ones )
2007-12-06 22:10:11 +01:00
* do not like vertex shaders in feedback mode and return an error , even though it should be valid
* according to the spec .
*
* We don ' t want to enable this on all cards , as it adds an extra instruction per texcoord used . This
* makes the shader slower and eats instruction slots which should be available to the d3d app .
2008-02-14 18:38:02 +01:00
*
2008-03-01 21:10:38 +01:00
* ATI Radeon HD 2 xxx cards on MacOS have the issue . Instead of checking for the buggy cards , blacklist
* all radeon cards on Macs and whitelist the good ones . That way we ' re prepared for the future . If
* this workaround is activated on cards that do not need it , it won ' t break things , just affect
* performance negatively .
2007-12-06 22:10:11 +01:00
*/
2008-02-14 18:38:02 +01:00
if ( gl_info - > gl_vendor = = VENDOR_INTEL | |
( gl_info - > gl_vendor = = VENDOR_ATI & & gl_info - > gl_card ! = CARD_ATI_RADEON_X1600 ) ) {
2007-12-06 22:10:11 +01:00
TRACE ( " Enabling vertex texture coord fixes in vertex shaders \n " ) ;
gl_info - > set_texcoord_w = TRUE ;
}
2007-11-08 22:10:17 +01:00
}
2008-02-06 16:09:29 +01:00
2008-07-09 01:59:10 +02:00
/* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
* these cards only support GL_ARB_texture_rectangle ( D3DPTEXTURECAPS_NONPOW2CONDITIONAL ) .
* If real NP2 textures are used , the driver falls back to software . We could just remove the
* extension and use GL_ARB_texture_rectangle instead , but texture_rectangle is inconventient
* due to the non - normalized texture coordinates . Thus set an internal extension flag ,
* GL_WINE_normalized_texrect , which signals the code that it can use non power of two textures
* as per GL_ARB_texture_non_power_of_two , but has to stick to the texture_rectangle limits .
*
* fglrx doesn ' t advertise GL_ARB_texture_non_power_of_two , but it advertises opengl 2.0 which
* has this extension promoted to core . The extension loading code sets this extension supported
* due to that , so this code works on fglrx as well .
*/
if ( gl_info - > supported [ ARB_TEXTURE_NON_POWER_OF_TWO ] & & gl_info - > gl_vendor = = VENDOR_ATI ) {
if ( gl_info - > gl_card = = CARD_ATI_RADEON_X700 | | gl_info - > gl_card = = CARD_ATI_RADEON_X1600 | |
gl_info - > gl_card = = CARD_ATI_RADEON_9500 | | gl_info - > gl_card = = CARD_ATI_RADEON_8500 | |
gl_info - > gl_card = = CARD_ATI_RADEON_7200 | | gl_info - > gl_card = = CARD_ATI_RAGE_128PRO ) {
TRACE ( " GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing \n " ) ;
gl_info - > supported [ ARB_TEXTURE_NON_POWER_OF_TWO ] = FALSE ;
gl_info - > supported [ WINE_NORMALIZED_TEXRECT ] = TRUE ;
}
}
2008-08-03 00:59:48 +02:00
/* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
* doesn ' t explicitly advertise the ARB_tex_npot extension in the GL extension string .
* This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
* within the limits enforced by the ARB_texture_rectangle extension . This however is not true for the
* FX series , which instantly falls back to a slower software path as soon as ARB_tex_npot is used .
2008-09-01 17:01:17 +02:00
* We therefore completely remove ARB_tex_npot from the list of supported extensions .
2008-08-03 00:59:48 +02:00
*
* Note that wine_normalized_texrect can ' t be used in this case because internally it uses ARB_tex_npot ,
* triggering the software fallback . There is not much we can do here apart from disabling the
* software - emulated extension and reenable ARB_tex_rect ( which was previously disabled
* in IWineD3DImpl_FillGLCaps ) .
* This fixup removes performance problems on both the FX 5900 and FX 5700 ( e . g . for framebuffer
* post - processing effects in the game " Max Payne 2 " ) .
* The behaviour can be verified through a simple test app attached in bugreport # 14724.
*/
if ( gl_info - > supported [ ARB_TEXTURE_NON_POWER_OF_TWO ] & & gl_info - > gl_vendor = = VENDOR_NVIDIA ) {
if ( gl_info - > gl_card = = CARD_NVIDIA_GEFORCEFX_5800 | | gl_info - > gl_card = = CARD_NVIDIA_GEFORCEFX_5600 ) {
TRACE ( " GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing \n " ) ;
gl_info - > supported [ ARB_TEXTURE_NON_POWER_OF_TWO ] = FALSE ;
gl_info - > supported [ ARB_TEXTURE_RECTANGLE ] = TRUE ;
}
}
2008-02-11 01:55:11 +01:00
/* Find out if PBOs work as they are supposed to */
test_pbo_functionality ( gl_info ) ;
2008-02-06 16:09:29 +01:00
/* Fixup the driver version */
for ( i = 0 ; i < ( sizeof ( driver_version_table ) / sizeof ( driver_version_table [ 0 ] ) ) ; i + + ) {
if ( gl_info - > gl_vendor = = driver_version_table [ i ] . vendor & &
gl_info - > gl_card = = driver_version_table [ i ] . card ) {
TRACE_ ( d3d_caps ) ( " Found card 0x%04x, 0x%04x in driver version DB \n " , gl_info - > gl_vendor , gl_info - > gl_card ) ;
gl_info - > driver_version = MAKEDWORD_VERSION ( driver_version_table [ i ] . lopart_hi ,
driver_version_table [ i ] . lopart_lo ) ;
gl_info - > driver_version_hipart = MAKEDWORD_VERSION ( driver_version_table [ i ] . hipart_hi ,
driver_version_table [ i ] . hipart_lo ) ;
break ;
}
}
2007-11-08 22:10:17 +01:00
}
2008-11-28 15:30:11 +01:00
static void WINE_GLAPI invalid_func ( const void * data )
{
2007-12-19 17:10:02 +01:00
ERR ( " Invalid vertex attribute function called \n " ) ;
DebugBreak ( ) ;
}
2008-11-28 15:30:11 +01:00
static void WINE_GLAPI invalid_texcoord_func ( GLenum unit , const void * data )
{
2008-09-24 15:56:48 +02:00
ERR ( " Invalid texcoord function called \n " ) ;
DebugBreak ( ) ;
}
2007-12-19 17:10:02 +01:00
/* Helper functions for providing vertex data to opengl. The arrays are initialized based on
* the extension detection and are used in drawStridedSlow
*/
2008-11-28 15:30:11 +01:00
static void WINE_GLAPI position_d3dcolor ( const void * data )
{
DWORD pos = * ( ( const DWORD * ) data ) ;
2007-12-19 17:10:02 +01:00
FIXME ( " Add a test for fixed function position from d3dcolor type \n " ) ;
glVertex4s ( D3DCOLOR_B_R ( pos ) ,
D3DCOLOR_B_G ( pos ) ,
D3DCOLOR_B_B ( pos ) ,
D3DCOLOR_B_A ( pos ) ) ;
}
2008-11-28 15:30:11 +01:00
static void WINE_GLAPI position_float4 ( const void * data )
{
const GLfloat * pos = data ;
2007-12-19 17:10:02 +01:00
2007-12-25 09:18:21 +01:00
if ( pos [ 3 ] < eps & & pos [ 3 ] > - eps )
glVertex3fv ( pos ) ;
else {
float w = 1.0 / pos [ 3 ] ;
glVertex4f ( pos [ 0 ] * w , pos [ 1 ] * w , pos [ 2 ] * w , w ) ;
}
2007-12-19 17:10:02 +01:00
}
2008-11-28 15:30:11 +01:00
static void WINE_GLAPI diffuse_d3dcolor ( const void * data )
{
DWORD diffuseColor = * ( ( const DWORD * ) data ) ;
2007-12-19 17:10:02 +01:00
glColor4ub ( D3DCOLOR_B_R ( diffuseColor ) ,
D3DCOLOR_B_G ( diffuseColor ) ,
D3DCOLOR_B_B ( diffuseColor ) ,
D3DCOLOR_B_A ( diffuseColor ) ) ;
}
2008-11-28 15:30:11 +01:00
static void WINE_GLAPI specular_d3dcolor ( const void * data )
{
DWORD specularColor = * ( ( const DWORD * ) data ) ;
2009-03-11 10:15:09 +01:00
GLbyte d [ ] = { D3DCOLOR_B_R ( specularColor ) ,
D3DCOLOR_B_G ( specularColor ) ,
D3DCOLOR_B_B ( specularColor ) } ;
2007-12-19 17:10:02 +01:00
2009-03-11 10:15:09 +01:00
specular_func_3ubv ( d ) ;
2007-12-19 17:10:02 +01:00
}
2008-11-28 15:30:11 +01:00
static void WINE_GLAPI warn_no_specular_func ( const void * data )
{
2007-12-19 17:10:02 +01:00
WARN ( " GL_EXT_secondary_color not supported \n " ) ;
}
2008-12-02 15:31:17 +01:00
static void fillGLAttribFuncs ( const WineD3D_GL_Info * gl_info )
2008-11-28 15:30:11 +01:00
{
2009-03-27 10:25:56 +01:00
position_funcs [ WINED3D_FFP_EMIT_FLOAT1 ] = invalid_func ;
position_funcs [ WINED3D_FFP_EMIT_FLOAT2 ] = invalid_func ;
position_funcs [ WINED3D_FFP_EMIT_FLOAT3 ] = ( glAttribFunc ) glVertex3fv ;
position_funcs [ WINED3D_FFP_EMIT_FLOAT4 ] = position_float4 ;
position_funcs [ WINED3D_FFP_EMIT_D3DCOLOR ] = position_d3dcolor ;
position_funcs [ WINED3D_FFP_EMIT_UBYTE4 ] = invalid_func ;
position_funcs [ WINED3D_FFP_EMIT_SHORT2 ] = invalid_func ;
position_funcs [ WINED3D_FFP_EMIT_SHORT4 ] = ( glAttribFunc ) glVertex2sv ;
position_funcs [ WINED3D_FFP_EMIT_UBYTE4N ] = invalid_func ;
position_funcs [ WINED3D_FFP_EMIT_SHORT2N ] = invalid_func ;
position_funcs [ WINED3D_FFP_EMIT_SHORT4N ] = invalid_func ;
position_funcs [ WINED3D_FFP_EMIT_USHORT2N ] = invalid_func ;
position_funcs [ WINED3D_FFP_EMIT_USHORT4N ] = invalid_func ;
position_funcs [ WINED3D_FFP_EMIT_UDEC3 ] = invalid_func ;
position_funcs [ WINED3D_FFP_EMIT_DEC3N ] = invalid_func ;
position_funcs [ WINED3D_FFP_EMIT_FLOAT16_2 ] = invalid_func ;
position_funcs [ WINED3D_FFP_EMIT_FLOAT16_4 ] = invalid_func ;
diffuse_funcs [ WINED3D_FFP_EMIT_FLOAT1 ] = invalid_func ;
diffuse_funcs [ WINED3D_FFP_EMIT_FLOAT2 ] = invalid_func ;
diffuse_funcs [ WINED3D_FFP_EMIT_FLOAT3 ] = ( glAttribFunc ) glColor3fv ;
diffuse_funcs [ WINED3D_FFP_EMIT_FLOAT4 ] = ( glAttribFunc ) glColor4fv ;
diffuse_funcs [ WINED3D_FFP_EMIT_D3DCOLOR ] = diffuse_d3dcolor ;
diffuse_funcs [ WINED3D_FFP_EMIT_UBYTE4 ] = invalid_func ;
diffuse_funcs [ WINED3D_FFP_EMIT_SHORT2 ] = invalid_func ;
diffuse_funcs [ WINED3D_FFP_EMIT_SHORT4 ] = invalid_func ;
diffuse_funcs [ WINED3D_FFP_EMIT_UBYTE4N ] = ( glAttribFunc ) glColor4ubv ;
diffuse_funcs [ WINED3D_FFP_EMIT_SHORT2N ] = invalid_func ;
diffuse_funcs [ WINED3D_FFP_EMIT_SHORT4N ] = ( glAttribFunc ) glColor4sv ;
diffuse_funcs [ WINED3D_FFP_EMIT_USHORT2N ] = invalid_func ;
diffuse_funcs [ WINED3D_FFP_EMIT_USHORT4N ] = ( glAttribFunc ) glColor4usv ;
diffuse_funcs [ WINED3D_FFP_EMIT_UDEC3 ] = invalid_func ;
diffuse_funcs [ WINED3D_FFP_EMIT_DEC3N ] = invalid_func ;
diffuse_funcs [ WINED3D_FFP_EMIT_FLOAT16_2 ] = invalid_func ;
diffuse_funcs [ WINED3D_FFP_EMIT_FLOAT16_4 ] = invalid_func ;
2007-12-19 17:10:02 +01:00
/* No 4 component entry points here */
2009-03-27 10:25:56 +01:00
specular_funcs [ WINED3D_FFP_EMIT_FLOAT1 ] = invalid_func ;
specular_funcs [ WINED3D_FFP_EMIT_FLOAT2 ] = invalid_func ;
2007-12-19 17:10:02 +01:00
if ( GL_SUPPORT ( EXT_SECONDARY_COLOR ) ) {
2009-03-27 10:25:56 +01:00
specular_funcs [ WINED3D_FFP_EMIT_FLOAT3 ] = ( glAttribFunc ) GL_EXTCALL ( glSecondaryColor3fvEXT ) ;
2007-12-19 17:10:02 +01:00
} else {
2009-03-27 10:25:56 +01:00
specular_funcs [ WINED3D_FFP_EMIT_FLOAT3 ] = warn_no_specular_func ;
2007-12-19 17:10:02 +01:00
}
2009-03-27 10:25:56 +01:00
specular_funcs [ WINED3D_FFP_EMIT_FLOAT4 ] = invalid_func ;
2007-12-19 17:10:02 +01:00
if ( GL_SUPPORT ( EXT_SECONDARY_COLOR ) ) {
2009-03-11 10:15:09 +01:00
specular_func_3ubv = ( glAttribFunc ) GL_EXTCALL ( glSecondaryColor3ubvEXT ) ;
2009-03-27 10:25:56 +01:00
specular_funcs [ WINED3D_FFP_EMIT_D3DCOLOR ] = specular_d3dcolor ;
2007-12-19 17:10:02 +01:00
} else {
2009-03-27 10:25:56 +01:00
specular_funcs [ WINED3D_FFP_EMIT_D3DCOLOR ] = warn_no_specular_func ;
2007-12-19 17:10:02 +01:00
}
2009-03-27 10:25:56 +01:00
specular_funcs [ WINED3D_FFP_EMIT_UBYTE4 ] = invalid_func ;
specular_funcs [ WINED3D_FFP_EMIT_SHORT2 ] = invalid_func ;
specular_funcs [ WINED3D_FFP_EMIT_SHORT4 ] = invalid_func ;
specular_funcs [ WINED3D_FFP_EMIT_UBYTE4N ] = invalid_func ;
specular_funcs [ WINED3D_FFP_EMIT_SHORT2N ] = invalid_func ;
specular_funcs [ WINED3D_FFP_EMIT_SHORT4N ] = invalid_func ;
specular_funcs [ WINED3D_FFP_EMIT_USHORT2N ] = invalid_func ;
specular_funcs [ WINED3D_FFP_EMIT_USHORT4N ] = invalid_func ;
specular_funcs [ WINED3D_FFP_EMIT_UDEC3 ] = invalid_func ;
specular_funcs [ WINED3D_FFP_EMIT_DEC3N ] = invalid_func ;
specular_funcs [ WINED3D_FFP_EMIT_FLOAT16_2 ] = invalid_func ;
specular_funcs [ WINED3D_FFP_EMIT_FLOAT16_4 ] = invalid_func ;
2007-12-19 17:10:02 +01:00
/* Only 3 component entry points here. Test how others behave. Float4 normals are used
* by one of our tests , trying to pass it to the pixel shader , which fails on Windows .
*/
2009-03-27 10:25:56 +01:00
normal_funcs [ WINED3D_FFP_EMIT_FLOAT1 ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_FLOAT2 ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_FLOAT3 ] = ( glAttribFunc ) glNormal3fv ;
normal_funcs [ WINED3D_FFP_EMIT_FLOAT4 ] = ( glAttribFunc ) glNormal3fv ; /* Just ignore the 4th value */
normal_funcs [ WINED3D_FFP_EMIT_D3DCOLOR ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_UBYTE4 ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_SHORT2 ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_SHORT4 ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_UBYTE4N ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_SHORT2N ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_SHORT4N ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_USHORT2N ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_USHORT4N ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_UDEC3 ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_DEC3N ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_FLOAT16_2 ] = invalid_func ;
normal_funcs [ WINED3D_FFP_EMIT_FLOAT16_4 ] = invalid_func ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_FLOAT1 ] = ( glMultiTexCoordFunc ) GL_EXTCALL ( glMultiTexCoord1fvARB ) ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_FLOAT2 ] = ( glMultiTexCoordFunc ) GL_EXTCALL ( glMultiTexCoord2fvARB ) ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_FLOAT3 ] = ( glMultiTexCoordFunc ) GL_EXTCALL ( glMultiTexCoord3fvARB ) ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_FLOAT4 ] = ( glMultiTexCoordFunc ) GL_EXTCALL ( glMultiTexCoord4fvARB ) ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_D3DCOLOR ] = invalid_texcoord_func ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_UBYTE4 ] = invalid_texcoord_func ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_SHORT2 ] = ( glMultiTexCoordFunc ) GL_EXTCALL ( glMultiTexCoord2svARB ) ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_SHORT4 ] = ( glMultiTexCoordFunc ) GL_EXTCALL ( glMultiTexCoord4svARB ) ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_UBYTE4N ] = invalid_texcoord_func ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_SHORT2N ] = invalid_texcoord_func ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_SHORT4N ] = invalid_texcoord_func ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_USHORT2N ] = invalid_texcoord_func ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_USHORT4N ] = invalid_texcoord_func ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_UDEC3 ] = invalid_texcoord_func ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_DEC3N ] = invalid_texcoord_func ;
2008-09-24 15:56:48 +02:00
if ( GL_SUPPORT ( NV_HALF_FLOAT ) )
{
2009-03-27 10:25:56 +01:00
multi_texcoord_funcs [ WINED3D_FFP_EMIT_FLOAT16_2 ] = ( glMultiTexCoordFunc ) GL_EXTCALL ( glMultiTexCoord2hvNV ) ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_FLOAT16_4 ] = ( glMultiTexCoordFunc ) GL_EXTCALL ( glMultiTexCoord4hvNV ) ;
2008-09-24 15:56:48 +02:00
} else {
2009-03-27 10:25:56 +01:00
multi_texcoord_funcs [ WINED3D_FFP_EMIT_FLOAT16_2 ] = invalid_texcoord_func ;
multi_texcoord_funcs [ WINED3D_FFP_EMIT_FLOAT16_4 ] = invalid_texcoord_func ;
2008-09-24 15:56:48 +02:00
}
2007-12-19 17:10:02 +01:00
}
2009-03-11 10:15:09 +01:00
BOOL InitAdapters ( IWineD3DImpl * This )
{
2008-11-23 12:43:15 +01:00
static HMODULE mod_gl ;
2007-06-09 14:27:41 +02:00
BOOL ret ;
2007-07-16 19:59:41 +02:00
int ps_selected_mode , vs_selected_mode ;
2007-06-09 14:27:41 +02:00
/* No need to hold any lock. The calling library makes sure only one thread calls
* wined3d simultaneously
*/
TRACE ( " Initializing adapters \n " ) ;
2007-08-24 19:16:30 +02:00
if ( ! mod_gl ) {
# ifdef USE_WIN32_OPENGL
# define USE_GL_FUNC(pfn) pfn = (void*)GetProcAddress(mod_gl, #pfn);
mod_gl = LoadLibraryA ( " opengl32.dll " ) ;
if ( ! mod_gl ) {
ERR ( " Can't load opengl32.dll! \n " ) ;
2008-03-28 23:04:17 +01:00
goto nogl_adapter ;
2007-08-24 19:16:30 +02:00
}
# else
# define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);
/* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 (glXGetProcAddress wrapper) instead of opengl32's */
mod_gl = GetModuleHandleA ( " gdi32.dll " ) ;
# endif
}
/* Load WGL core functions from opengl32.dll */
# define USE_WGL_FUNC(pfn) p##pfn = (void*)GetProcAddress(mod_gl, #pfn);
WGL_FUNCS_GEN ;
# undef USE_WGL_FUNC
if ( ! pwglGetProcAddress ) {
ERR ( " Unable to load wglGetProcAddress! \n " ) ;
2008-03-28 23:04:17 +01:00
goto nogl_adapter ;
2007-08-24 19:16:30 +02:00
}
2007-08-29 21:43:57 +02:00
/* Dynamically load all GL core functions */
2007-08-24 19:16:30 +02:00
GL_FUNCS_GEN ;
# undef USE_GL_FUNC
2008-07-30 17:53:33 +02:00
/* Load glFinish and glFlush from opengl32.dll even if we're not using WIN32 opengl
* otherwise because we have to use winex11 . drv ' s override
*/
2008-11-23 12:43:15 +01:00
# ifdef USE_WIN32_OPENGL
glFinish = ( void * ) GetProcAddress ( mod_gl , " glFinish " ) ;
glFlush = ( void * ) GetProcAddress ( mod_gl , " glFlush " ) ;
# else
glFinish = ( void * ) pwglGetProcAddress ( " wglFinish " ) ;
glFlush = ( void * ) pwglGetProcAddress ( " wglFlush " ) ;
# endif
2008-07-30 17:53:33 +02:00
2008-12-15 19:38:48 +01:00
glEnableWINE = glEnable ;
glDisableWINE = glDisable ;
2007-06-09 14:27:41 +02:00
/* For now only one default adapter */
{
2009-03-11 10:15:09 +01:00
struct WineD3DAdapter * adapter = & This - > adapters [ 0 ] ;
const WineD3D_GL_Info * gl_info = & adapter - > gl_info ;
2007-08-24 19:16:30 +02:00
int iPixelFormat ;
int res ;
2008-05-03 16:37:09 +02:00
int i ;
2007-08-24 19:16:30 +02:00
WineD3D_PixelFormat * cfgs ;
2007-08-13 16:47:17 +02:00
DISPLAY_DEVICEW DisplayDevice ;
2007-08-27 17:49:11 +02:00
HDC hdc ;
2007-08-13 16:47:17 +02:00
2007-06-09 14:27:41 +02:00
TRACE ( " Initializing default adapter \n " ) ;
2009-03-11 10:15:09 +01:00
adapter - > num = 0 ;
adapter - > monitorPoint . x = - 1 ;
adapter - > monitorPoint . y = - 1 ;
2007-06-09 14:27:41 +02:00
2007-08-24 19:16:30 +02:00
if ( ! WineD3D_CreateFakeGLContext ( ) ) {
ERR ( " Failed to get a gl context for default adapter \n " ) ;
WineD3D_ReleaseFakeGLContext ( ) ;
2008-03-28 23:04:17 +01:00
goto nogl_adapter ;
2007-08-24 19:16:30 +02:00
}
2009-03-11 10:15:09 +01:00
ret = IWineD3DImpl_FillGLCaps ( & adapter - > gl_info ) ;
2007-06-08 14:16:37 +02:00
if ( ! ret ) {
2007-06-09 14:27:41 +02:00
ERR ( " Failed to initialize gl caps for default adapter \n " ) ;
2007-08-24 19:16:30 +02:00
WineD3D_ReleaseFakeGLContext ( ) ;
2008-03-28 23:04:17 +01:00
goto nogl_adapter ;
2007-06-09 14:27:41 +02:00
}
2009-03-11 10:15:09 +01:00
ret = initPixelFormats ( & adapter - > gl_info ) ;
2007-07-27 13:22:54 +02:00
if ( ! ret ) {
ERR ( " Failed to init gl formats \n " ) ;
2007-08-24 19:16:30 +02:00
WineD3D_ReleaseFakeGLContext ( ) ;
2008-03-28 23:04:17 +01:00
goto nogl_adapter ;
2007-07-27 13:22:54 +02:00
}
2007-08-27 17:49:11 +02:00
hdc = pwglGetCurrentDC ( ) ;
2007-08-29 01:07:26 +02:00
if ( ! hdc ) {
2007-08-27 17:49:11 +02:00
ERR ( " Failed to get gl HDC \n " ) ;
WineD3D_ReleaseFakeGLContext ( ) ;
2008-03-28 23:04:17 +01:00
goto nogl_adapter ;
2007-08-27 17:49:11 +02:00
}
2009-03-11 10:15:09 +01:00
adapter - > driver = " Display " ;
adapter - > description = " Direct3D HAL " ;
2007-07-16 19:59:41 +02:00
2007-09-23 00:46:21 +02:00
/* Use the VideoRamSize registry setting when set */
if ( wined3d_settings . emulated_textureram )
2009-03-11 10:15:09 +01:00
adapter - > TextureRam = wined3d_settings . emulated_textureram ;
2007-09-23 00:46:21 +02:00
else
2009-03-11 10:15:09 +01:00
adapter - > TextureRam = adapter - > gl_info . vidmem ;
adapter - > UsedTextureRam = 0 ;
TRACE ( " Emulating %dMB of texture ram \n " , adapter - > TextureRam / ( 1024 * 1024 ) ) ;
2007-09-23 00:46:21 +02:00
2007-08-13 16:47:17 +02:00
/* Initialize the Adapter's DeviceName which is required for ChangeDisplaySettings and friends */
DisplayDevice . cb = sizeof ( DisplayDevice ) ;
EnumDisplayDevicesW ( NULL , 0 /* Adapter 0 = iDevNum 0 */ , & DisplayDevice , 0 ) ;
TRACE ( " DeviceName: %s \n " , debugstr_w ( DisplayDevice . DeviceName ) ) ;
2009-03-11 10:15:09 +01:00
strcpyW ( adapter - > DeviceName , DisplayDevice . DeviceName ) ;
2007-08-13 16:47:17 +02:00
2009-03-15 11:30:10 +01:00
if ( GL_SUPPORT ( WGL_ARB_PIXEL_FORMAT ) )
2009-03-11 10:15:09 +01:00
{
2009-03-15 11:30:10 +01:00
int attribute ;
int attribs [ 10 ] ;
int values [ 10 ] ;
int nAttribs = 0 ;
attribute = WGL_NUMBER_PIXEL_FORMATS_ARB ;
GL_EXTCALL ( wglGetPixelFormatAttribivARB ( hdc , 0 , 0 , 1 , & attribute , & adapter - > nCfgs ) ) ;
adapter - > cfgs = HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , adapter - > nCfgs * sizeof ( WineD3D_PixelFormat ) ) ;
cfgs = adapter - > cfgs ;
attribs [ nAttribs + + ] = WGL_RED_BITS_ARB ;
attribs [ nAttribs + + ] = WGL_GREEN_BITS_ARB ;
attribs [ nAttribs + + ] = WGL_BLUE_BITS_ARB ;
attribs [ nAttribs + + ] = WGL_ALPHA_BITS_ARB ;
attribs [ nAttribs + + ] = WGL_DEPTH_BITS_ARB ;
attribs [ nAttribs + + ] = WGL_STENCIL_BITS_ARB ;
attribs [ nAttribs + + ] = WGL_DRAW_TO_WINDOW_ARB ;
attribs [ nAttribs + + ] = WGL_PIXEL_TYPE_ARB ;
attribs [ nAttribs + + ] = WGL_DOUBLE_BUFFER_ARB ;
attribs [ nAttribs + + ] = WGL_AUX_BUFFERS_ARB ;
for ( iPixelFormat = 1 ; iPixelFormat < = adapter - > nCfgs ; + + iPixelFormat )
{
res = GL_EXTCALL ( wglGetPixelFormatAttribivARB ( hdc , iPixelFormat , 0 , nAttribs , attribs , values ) ) ;
2007-08-24 19:16:30 +02:00
2009-03-15 11:30:10 +01:00
if ( ! res )
continue ;
/* Cache the pixel format */
cfgs - > iPixelFormat = iPixelFormat ;
cfgs - > redSize = values [ 0 ] ;
cfgs - > greenSize = values [ 1 ] ;
cfgs - > blueSize = values [ 2 ] ;
cfgs - > alphaSize = values [ 3 ] ;
cfgs - > depthSize = values [ 4 ] ;
cfgs - > stencilSize = values [ 5 ] ;
cfgs - > windowDrawable = values [ 6 ] ;
cfgs - > iPixelType = values [ 7 ] ;
cfgs - > doubleBuffer = values [ 8 ] ;
cfgs - > auxBuffers = values [ 9 ] ;
cfgs - > pbufferDrawable = FALSE ;
/* Check for pbuffer support when it is around as wglGetPixelFormatAttribiv fails for unknown attributes. */
if ( GL_SUPPORT ( WGL_ARB_PBUFFER ) ) {
int attrib = WGL_DRAW_TO_PBUFFER_ARB ;
int value ;
if ( GL_EXTCALL ( wglGetPixelFormatAttribivARB ( hdc , iPixelFormat , 0 , 1 , & attrib , & value ) ) )
cfgs - > pbufferDrawable = value ;
}
cfgs - > numSamples = 0 ;
/* Check multisample support */
if ( GL_SUPPORT ( ARB_MULTISAMPLE ) ) {
int attrib [ 2 ] = { WGL_SAMPLE_BUFFERS_ARB , WGL_SAMPLES_ARB } ;
int value [ 2 ] ;
if ( GL_EXTCALL ( wglGetPixelFormatAttribivARB ( hdc , iPixelFormat , 0 , 2 , attrib , value ) ) ) {
/* value[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether multisampling is supported.
* value [ 1 ] = number of multi sample buffers */
if ( value [ 0 ] )
cfgs - > numSamples = value [ 1 ] ;
}
}
2007-08-24 19:16:30 +02:00
2009-03-15 11:30:10 +01:00
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 ) ;
cfgs + + ;
2008-03-16 17:37:38 +01:00
}
2009-03-15 11:30:10 +01:00
}
else
{
int nCfgs = DescribePixelFormat ( hdc , 0 , 0 , 0 ) ;
adapter - > cfgs = HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , nCfgs * sizeof ( WineD3D_PixelFormat ) ) ;
adapter - > nCfgs = 0 ; /* We won't accept all formats e.g. software accelerated ones will be skipped */
cfgs = adapter - > cfgs ;
for ( iPixelFormat = 1 ; iPixelFormat < = nCfgs ; iPixelFormat + + )
{
PIXELFORMATDESCRIPTOR ppfd ;
2007-08-24 19:16:30 +02:00
2009-03-15 11:30:10 +01:00
res = DescribePixelFormat ( hdc , iPixelFormat , sizeof ( PIXELFORMATDESCRIPTOR ) , & ppfd ) ;
if ( ! res )
continue ;
/* We only want HW acceleration using an OpenGL ICD driver.
* PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering
* PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD driver ( e . g . 3 dfx minigl )
*/
if ( ppfd . dwFlags & ( PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED ) )
{
TRACE ( " Skipping iPixelFormat=%d because it isn't ICD accelerated \n " , iPixelFormat ) ;
continue ;
2008-04-28 23:44:21 +02:00
}
2009-03-15 11:30:10 +01:00
cfgs - > iPixelFormat = iPixelFormat ;
cfgs - > redSize = ppfd . cRedBits ;
cfgs - > greenSize = ppfd . cGreenBits ;
cfgs - > blueSize = ppfd . cBlueBits ;
cfgs - > alphaSize = ppfd . cAlphaBits ;
cfgs - > depthSize = ppfd . cDepthBits ;
cfgs - > stencilSize = ppfd . cStencilBits ;
cfgs - > pbufferDrawable = 0 ;
cfgs - > windowDrawable = ( ppfd . dwFlags & PFD_DRAW_TO_WINDOW ) ? 1 : 0 ;
cfgs - > iPixelType = ( ppfd . iPixelType = = PFD_TYPE_RGBA ) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB ;
cfgs - > doubleBuffer = ( ppfd . dwFlags & PFD_DOUBLEBUFFER ) ? 1 : 0 ;
cfgs - > auxBuffers = ppfd . cAuxBuffers ;
cfgs - > numSamples = 0 ;
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 ) ;
cfgs + + ;
adapter - > nCfgs + + ;
2008-04-28 23:44:21 +02:00
}
2009-03-15 11:30:10 +01:00
/* 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 */
if ( ! adapter - > nCfgs )
{
ERR ( " Disabling Direct3D because no hardware accelerated pixel formats have been found! \n " ) ;
WineD3D_ReleaseFakeGLContext ( ) ;
HeapFree ( GetProcessHeap ( ) , 0 , adapter - > cfgs ) ;
goto nogl_adapter ;
}
2007-08-08 03:09:38 +02:00
}
2008-05-03 16:37:09 +02:00
/* D16, D24X8 and D24S8 are common depth / depth+stencil formats. All drivers support them though this doesn't
* mean that the format is offered in hardware . For instance Geforce8 cards don ' t have offer D16 in hardware
* but just fake it using D24 ( X8 ? ) which is fine . D3D also allows that .
* Some display drivers ( i915 on Linux ) only report mixed depth + stencil formats like D24S8 . MSDN clearly mentions
* that only on lockable formats ( e . g . D16_locked ) the bit order is guaranteed and that on other formats the
* driver is allowed to consume more bits EXCEPT for stencil bits .
*
* Mark an adapter with this broken stencil behavior .
*/
2009-03-11 10:15:09 +01:00
adapter - > brokenStencil = TRUE ;
for ( i = 0 , cfgs = adapter - > cfgs ; i < adapter - > nCfgs ; + + i )
{
2008-05-03 16:37:09 +02:00
/* Nearly all drivers offer depth formats without stencil, only on i915 this if-statement won't be entered. */
if ( cfgs [ i ] . depthSize & & ! cfgs [ i ] . stencilSize ) {
2009-03-11 10:15:09 +01:00
adapter - > brokenStencil = FALSE ;
2008-05-03 16:37:09 +02:00
break ;
}
}
2009-03-11 10:15:09 +01:00
fixup_extensions ( & adapter - > gl_info ) ;
add_gl_compat_wrappers ( & adapter - > gl_info ) ;
2007-11-08 22:08:08 +01:00
2008-02-24 10:19:01 +01:00
WineD3D_ReleaseFakeGLContext ( ) ;
2009-03-11 10:15:09 +01:00
select_shader_mode ( & adapter - > gl_info , WINED3DDEVTYPE_HAL , & ps_selected_mode , & vs_selected_mode ) ;
select_shader_max_constants ( ps_selected_mode , vs_selected_mode , & adapter - > gl_info ) ;
fillGLAttribFuncs ( & adapter - > gl_info ) ;
adapter - > opengl = TRUE ;
2007-06-09 14:27:41 +02:00
}
2009-03-11 10:15:09 +01:00
This - > adapter_count = 1 ;
TRACE ( " %u adapters successfully initialized \n " , This - > adapter_count ) ;
2007-06-09 14:27:41 +02:00
return TRUE ;
2008-03-28 23:04:17 +01:00
nogl_adapter :
/* Initialize an adapter for ddraw-only memory counting */
2009-03-11 10:15:09 +01:00
memset ( This - > adapters , 0 , sizeof ( This - > adapters ) ) ;
This - > adapters [ 0 ] . num = 0 ;
This - > adapters [ 0 ] . opengl = FALSE ;
This - > adapters [ 0 ] . monitorPoint . x = - 1 ;
This - > adapters [ 0 ] . monitorPoint . y = - 1 ;
This - > adapters [ 0 ] . driver = " Display " ;
This - > adapters [ 0 ] . description = " WineD3D DirectDraw Emulation " ;
2008-03-28 23:04:17 +01:00
if ( wined3d_settings . emulated_textureram ) {
2009-03-11 10:15:09 +01:00
This - > adapters [ 0 ] . TextureRam = wined3d_settings . emulated_textureram ;
2008-03-28 23:04:17 +01:00
} else {
2009-03-11 10:15:09 +01:00
This - > adapters [ 0 ] . TextureRam = 8 * 1024 * 1024 ; /* This is plenty for a DDraw-only card */
2008-03-28 23:04:17 +01:00
}
2009-03-13 10:44:17 +01:00
initPixelFormatsNoGL ( & This - > adapters [ 0 ] . gl_info ) ;
2009-03-11 10:15:09 +01:00
This - > adapter_count = 1 ;
2008-03-28 23:04:17 +01:00
return FALSE ;
2007-06-09 14:27:41 +02:00
}
2004-09-29 23:26:47 +02:00
/**********************************************************
* IWineD3D VTbl follows
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-06-06 21:50:35 +02:00
const IWineD3DVtbl IWineD3D_Vtbl =
2004-09-23 06:34:27 +02:00
{
2005-07-13 16:15:54 +02:00
/* IUnknown */
2004-09-23 06:34:27 +02:00
IWineD3DImpl_QueryInterface ,
IWineD3DImpl_AddRef ,
IWineD3DImpl_Release ,
2005-07-13 16:15:54 +02:00
/* IWineD3D */
2004-11-23 14:52:46 +01:00
IWineD3DImpl_GetParent ,
2004-09-28 04:12:12 +02:00
IWineD3DImpl_GetAdapterCount ,
IWineD3DImpl_RegisterSoftwareDevice ,
IWineD3DImpl_GetAdapterMonitor ,
IWineD3DImpl_GetAdapterModeCount ,
IWineD3DImpl_EnumAdapterModes ,
2004-09-29 23:26:47 +02:00
IWineD3DImpl_GetAdapterDisplayMode ,
2004-10-05 04:14:06 +02:00
IWineD3DImpl_GetAdapterIdentifier ,
IWineD3DImpl_CheckDeviceMultiSampleType ,
IWineD3DImpl_CheckDepthStencilMatch ,
IWineD3DImpl_CheckDeviceType ,
2004-10-06 02:05:29 +02:00
IWineD3DImpl_CheckDeviceFormat ,
IWineD3DImpl_CheckDeviceFormatConversion ,
2004-10-07 06:22:21 +02:00
IWineD3DImpl_GetDeviceCaps ,
IWineD3DImpl_CreateDevice
2004-09-23 06:34:27 +02:00
} ;